From 48ea2e926b5ad29c0747fbd90e605cc56fb78298 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 5 Nov 2017 07:36:36 -0500 Subject: media: cec: add the adap_monitor_pin_enable op Some devices can monitor the CEC pin using an interrupt, but you only want to enable the interrupt if you actually switch to pin monitoring mode. So add a new op that is called when pin monitoring needs to be switched on or off. Also fix a small bug where the initial CEC pin event was sent again when calling S_MODE twice with the same CEC_MODE_MONITOR_PIN mode. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/cec.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/media') diff --git a/include/media/cec.h b/include/media/cec.h index 16341210d3ba..dd781e928b72 100644 --- a/include/media/cec.h +++ b/include/media/cec.h @@ -122,6 +122,7 @@ struct cec_adap_ops { /* Low-level callbacks */ int (*adap_enable)(struct cec_adapter *adap, bool enable); int (*adap_monitor_all_enable)(struct cec_adapter *adap, bool enable); + int (*adap_monitor_pin_enable)(struct cec_adapter *adap, bool enable); int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr); int (*adap_transmit)(struct cec_adapter *adap, u8 attempts, u32 signal_free_time, struct cec_msg *msg); -- cgit From c8959a39fd47189a1474a4e92ffa34763589d6b0 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 22 Nov 2017 04:12:39 -0500 Subject: media: cec: disable the hardware when unregistered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the device is being unregistered disable the hardware, don't wait until cec_delete_adapter is called as the hardware may have disappeared by then. This would be the case for hotplugable devices. Signed-off-by: Hans Verkuil Reported-by: Bård Eirik Winther Tested-by: Bård Eirik Winther Signed-off-by: Mauro Carvalho Chehab --- include/media/cec.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/media') diff --git a/include/media/cec.h b/include/media/cec.h index dd781e928b72..1c6a797cb6d4 100644 --- a/include/media/cec.h +++ b/include/media/cec.h @@ -230,6 +230,18 @@ static inline bool cec_is_sink(const struct cec_adapter *adap) return adap->phys_addr == 0; } +/** + * cec_is_registered() - is the CEC adapter registered? + * + * @adap: the CEC adapter, may be NULL. + * + * Return: true if the adapter is registered, false otherwise. + */ +static inline bool cec_is_registered(const struct cec_adapter *adap) +{ + return adap && adap->devnode.registered; +} + #define cec_phys_addr_exp(pa) \ ((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf -- cgit From afc7f24c01034b7820365d9fa64822504b4dc35d Mon Sep 17 00:00:00 2001 From: Sean Young Date: Wed, 18 Oct 2017 09:39:12 -0400 Subject: media: rc: i2c: set parent of rc device and improve name With the parent set for the rc device, the messages clearly state that it is attached via i2c. The additional printk is unnecessary. These are the old messages: rc rc1: i2c IR (Hauppauge WinTV PVR-150 as /devices/virtual/rc/rc1 ir-kbd-i2c: i2c IR (Hauppauge WinTV PVR-150 detected at i2c-10/10-0071/ir0 [ivtv i2c driver #0] Now we simply get: rc rc1: Hauppauge WinTV PVR-150 as /devices/pci0000:00/0000:00:1e.0/0000:02:00.0/i2c-10/10-0071/rc/rc1 Note that we no longer copy the name. I've checked all call sites to verfiy this is not a problem. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/i2c/ir-kbd-i2c.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/media') diff --git a/include/media/i2c/ir-kbd-i2c.h b/include/media/i2c/ir-kbd-i2c.h index 76491c62c254..1a9df1ae533f 100644 --- a/include/media/i2c/ir-kbd-i2c.h +++ b/include/media/i2c/ir-kbd-i2c.h @@ -19,7 +19,6 @@ struct IR_i2c { u32 polling_interval; /* in ms */ struct delayed_work work; - char name[32]; char phys[32]; int (*get_key)(struct IR_i2c *ir, enum rc_proto *protocol, -- cgit From acaa34bf06e963f0b9481a3c16bfd6867e2369a0 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 21 Oct 2017 08:16:47 -0400 Subject: media: rc: implement zilog transmitter This code implements the transmitter which is currently implemented in the staging lirc_zilog driver. The new code does not need a signal database, iow. the haup-ir-blaster.bin firmware file is no longer needed, and the driver does not know anything about the keycodes in that file. Instead, the new driver can send raw IR, but the hardware is limited to few different lengths of pulse and spaces, so it is best to use generated IR rather than recorded IR. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/i2c/ir-kbd-i2c.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/media') diff --git a/include/media/i2c/ir-kbd-i2c.h b/include/media/i2c/ir-kbd-i2c.h index 1a9df1ae533f..9f47d6a48cff 100644 --- a/include/media/i2c/ir-kbd-i2c.h +++ b/include/media/i2c/ir-kbd-i2c.h @@ -23,6 +23,11 @@ struct IR_i2c { int (*get_key)(struct IR_i2c *ir, enum rc_proto *protocol, u32 *scancode, u8 *toggle); + /* tx */ + struct i2c_client *tx_c; + struct mutex lock; /* do not poll Rx during Tx */ + unsigned int carrier; + unsigned int duty_cycle; }; enum ir_kbd_get_key_fn { -- cgit From 4e3cd001fde13dfd4a91888f908b2a07fd0a4047 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 8 Jun 2017 05:10:41 -0400 Subject: media: lirc: remove LIRCCODE and LIRC_GET_LENGTH LIRCCODE is a lirc mode where a driver produces driver-dependent codes for receive and transmit. No driver uses this any more. The LIRC_GET_LENGTH ioctl was used for this mode only. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/lirc_dev.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include/media') diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index 857da67bd931..0a03dd9e5a68 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -9,8 +9,6 @@ #ifndef _LINUX_LIRC_DEV_H #define _LINUX_LIRC_DEV_H -#define BUFLEN 16 - #include #include #include @@ -117,7 +115,6 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, * * @name: used for logging * @minor: the minor device (/dev/lircX) number for the device - * @code_length: length of a remote control key code expressed in bits * @features: lirc compatible hardware features, like LIRC_MODE_RAW, * LIRC_CAN\_\*, as defined at include/media/lirc.h. * @buffer_size: Number of FIFO buffers with @chunk_size size. @@ -142,7 +139,6 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, struct lirc_dev { char name[40]; unsigned int minor; - __u32 code_length; __u32 features; unsigned int buffer_size; /* in chunks holding one code each */ -- cgit From 9b6192589be788dec73a0e99fe49b8f8ddaf825e Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 25 Feb 2017 06:51:29 -0500 Subject: media: lirc: implement scancode sending This introduces a new lirc mode: scancode. Any device which can send raw IR can now also send scancodes. int main() { int mode, fd = open("/dev/lirc0", O_RDWR); mode = LIRC_MODE_SCANCODE; if (ioctl(fd, LIRC_SET_SEND_MODE, &mode)) { // kernel too old or lirc does not support transmit } struct lirc_scancode scancode = { .scancode = 0x1e3d, .rc_proto = RC_PROTO_RC5, }; write(fd, &scancode, sizeof(scancode)); close(fd); } The other fields of lirc_scancode must be set to 0. Note that toggle (rc5, rc6) and repeats (nec) are not implemented. Nor is there a method for holding down a key for a period. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/rc-map.h | 54 +------------------------------------------------- 1 file changed, 1 insertion(+), 53 deletions(-) (limited to 'include/media') diff --git a/include/media/rc-map.h b/include/media/rc-map.h index 72197cb43781..7046734b3895 100644 --- a/include/media/rc-map.h +++ b/include/media/rc-map.h @@ -10,59 +10,7 @@ */ #include - -/** - * enum rc_proto - the Remote Controller protocol - * - * @RC_PROTO_UNKNOWN: Protocol not known - * @RC_PROTO_OTHER: Protocol known but proprietary - * @RC_PROTO_RC5: Philips RC5 protocol - * @RC_PROTO_RC5X_20: Philips RC5x 20 bit protocol - * @RC_PROTO_RC5_SZ: StreamZap variant of RC5 - * @RC_PROTO_JVC: JVC protocol - * @RC_PROTO_SONY12: Sony 12 bit protocol - * @RC_PROTO_SONY15: Sony 15 bit protocol - * @RC_PROTO_SONY20: Sony 20 bit protocol - * @RC_PROTO_NEC: NEC protocol - * @RC_PROTO_NECX: Extended NEC protocol - * @RC_PROTO_NEC32: NEC 32 bit protocol - * @RC_PROTO_SANYO: Sanyo protocol - * @RC_PROTO_MCIR2_KBD: RC6-ish MCE keyboard - * @RC_PROTO_MCIR2_MSE: RC6-ish MCE mouse - * @RC_PROTO_RC6_0: Philips RC6-0-16 protocol - * @RC_PROTO_RC6_6A_20: Philips RC6-6A-20 protocol - * @RC_PROTO_RC6_6A_24: Philips RC6-6A-24 protocol - * @RC_PROTO_RC6_6A_32: Philips RC6-6A-32 protocol - * @RC_PROTO_RC6_MCE: MCE (Philips RC6-6A-32 subtype) protocol - * @RC_PROTO_SHARP: Sharp protocol - * @RC_PROTO_XMP: XMP protocol - * @RC_PROTO_CEC: CEC protocol - */ -enum rc_proto { - RC_PROTO_UNKNOWN = 0, - RC_PROTO_OTHER = 1, - RC_PROTO_RC5 = 2, - RC_PROTO_RC5X_20 = 3, - RC_PROTO_RC5_SZ = 4, - RC_PROTO_JVC = 5, - RC_PROTO_SONY12 = 6, - RC_PROTO_SONY15 = 7, - RC_PROTO_SONY20 = 8, - RC_PROTO_NEC = 9, - RC_PROTO_NECX = 10, - RC_PROTO_NEC32 = 11, - RC_PROTO_SANYO = 12, - RC_PROTO_MCIR2_KBD = 13, - RC_PROTO_MCIR2_MSE = 14, - RC_PROTO_RC6_0 = 15, - RC_PROTO_RC6_6A_20 = 16, - RC_PROTO_RC6_6A_24 = 17, - RC_PROTO_RC6_6A_32 = 18, - RC_PROTO_RC6_MCE = 19, - RC_PROTO_SHARP = 20, - RC_PROTO_XMP = 21, - RC_PROTO_CEC = 22, -}; +#include #define RC_PROTO_BIT_NONE 0ULL #define RC_PROTO_BIT_UNKNOWN BIT_ULL(RC_PROTO_UNKNOWN) -- cgit From cdfaa01c1cfeb828e6d3c0c5e4f54375fc3ccb95 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 25 Feb 2017 06:51:30 -0500 Subject: media: lirc: use the correct carrier for scancode transmit If the lirc device supports it, set the carrier for the protocol. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/rc-core.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/media') diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 314a1edb6189..ca48632ec8e2 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -309,6 +309,7 @@ int ir_raw_event_store_with_filter(struct rc_dev *dev, void ir_raw_event_set_idle(struct rc_dev *dev, bool idle); int ir_raw_encode_scancode(enum rc_proto protocol, u32 scancode, struct ir_raw_event *events, unsigned int max); +int ir_raw_encode_carrier(enum rc_proto protocol); static inline void ir_raw_event_reset(struct rc_dev *dev) { -- cgit From a60d64b15c20d178ba3a9bc3a542492b4ddeea70 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 23 Sep 2017 10:41:13 -0400 Subject: media: lirc: lirc interface should not be a raw decoder The lirc user interface exists as a raw decoder, which does not make much sense for transmit-only devices. In addition, we want to have lirc char devices for devices which do not use raw IR, i.e. scancode only devices. Note that rc-code, lirc_dev, ir-lirc-codec are now calling functions of each other, so they've been merged into one module rc-core to avoid circular dependencies. Since ir-lirc-codec no longer exists as separate codec module, there is no need for RC_DRIVER_IR_RAW_TX type drivers to call ir_raw_event_register(). Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/lirc_dev.h | 10 ---------- include/media/rc-core.h | 33 +++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 24 deletions(-) (limited to 'include/media') diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index 0a03dd9e5a68..dd0c078796e8 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -121,7 +121,6 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, * Only used if @rbuf is NULL. * @chunk_size: Size of each FIFO buffer. * Only used if @rbuf is NULL. - * @data: private per-driver data * @buf: if %NULL, lirc_dev will allocate and manage the buffer, * otherwise allocated by the caller which will * have to write to the buffer by other means, like irq's @@ -146,7 +145,6 @@ struct lirc_dev { struct lirc_buffer *buf; bool buf_internal; - void *data; struct rc_dev *rdev; const struct file_operations *fops; struct module *owner; @@ -168,14 +166,6 @@ int lirc_register_device(struct lirc_dev *d); void lirc_unregister_device(struct lirc_dev *d); -/* Must be called in the open fop before lirc_get_pdata() can be used */ -void lirc_init_pdata(struct inode *inode, struct file *file); - -/* Returns the private data stored in the lirc_dev - * associated with the given device file pointer. - */ -void *lirc_get_pdata(struct file *file); - /* default file operations * used by drivers if they override only some operations */ diff --git a/include/media/rc-core.h b/include/media/rc-core.h index ca48632ec8e2..5d6e415c7acc 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -20,6 +20,7 @@ #include #include #include +#include #include extern int rc_core_debug; @@ -115,6 +116,15 @@ enum rc_filter_type { * @max_timeout: maximum timeout supported by device * @rx_resolution : resolution (in ns) of input sampler * @tx_resolution: resolution (in ns) of output sampler + * @lirc_dev: lirc char device + * @carrier_low: when setting the carrier range, first the low end must be + * set with an ioctl and then the high end with another ioctl + * @gap_start: time when gap starts + * @gap_duration: duration of initial gap + * @gap: true if we're in a gap + * @send_timeout_reports: report timeouts in lirc raw IR. + * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or + * LIRC_MODE_PULSE * @change_protocol: allow changing the protocol used on hardware decoders * @open: callback to allow drivers to enable polling/irq when IR input device * is opened. @@ -174,6 +184,15 @@ struct rc_dev { u32 max_timeout; u32 rx_resolution; u32 tx_resolution; +#ifdef CONFIG_LIRC + struct lirc_dev *lirc_dev; + int carrier_low; + ktime_t gap_start; + u64 gap_duration; + bool gap; + bool send_timeout_reports; + u8 send_mode; +#endif int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); int (*open)(struct rc_dev *dev); void (*close)(struct rc_dev *dev); @@ -248,20 +267,6 @@ int devm_rc_register_device(struct device *parent, struct rc_dev *dev); */ void rc_unregister_device(struct rc_dev *dev); -/** - * rc_open - Opens a RC device - * - * @rdev: pointer to struct rc_dev. - */ -int rc_open(struct rc_dev *rdev); - -/** - * rc_close - Closes a RC device - * - * @rdev: pointer to struct rc_dev. - */ -void rc_close(struct rc_dev *rdev); - void rc_repeat(struct rc_dev *dev); void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u32 scancode, u8 toggle); -- cgit From 95bc71e199e50487054adfd8222c5105deddbbd9 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 23 Sep 2017 12:05:59 -0400 Subject: media: lirc: merge lirc_dev_fop_ioctl and ir_lirc_ioctl Calculate lirc features when necessary, and add LIRC_{S,G}ET_REC_MODE cases to ir_lirc_ioctl. This makes lirc_dev_fop_ioctl() unnecessary since all cases are already handled by ir_lirc_ioctl(). Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/lirc_dev.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include/media') diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index dd0c078796e8..86a3cf798775 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -115,8 +115,6 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, * * @name: used for logging * @minor: the minor device (/dev/lircX) number for the device - * @features: lirc compatible hardware features, like LIRC_MODE_RAW, - * LIRC_CAN\_\*, as defined at include/media/lirc.h. * @buffer_size: Number of FIFO buffers with @chunk_size size. * Only used if @rbuf is NULL. * @chunk_size: Size of each FIFO buffer. @@ -138,7 +136,6 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, struct lirc_dev { char name[40]; unsigned int minor; - __u32 features; unsigned int buffer_size; /* in chunks holding one code each */ unsigned int chunk_size; @@ -172,7 +169,6 @@ void lirc_unregister_device(struct lirc_dev *d); int lirc_dev_fop_open(struct inode *inode, struct file *file); int lirc_dev_fop_close(struct inode *inode, struct file *file); unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait); -long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg); ssize_t lirc_dev_fop_read(struct file *file, char __user *buffer, size_t length, loff_t *ppos); #endif -- cgit From 71695aff9fe036857596965635e2607cf561a230 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 23 Sep 2017 14:44:18 -0400 Subject: media: lirc: use kfifo rather than lirc_buffer for raw IR Since the only mode lirc devices can handle is raw IR, handle this in a plain kfifo. Remove lirc_buffer since this is no longer needed. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/lirc_dev.h | 109 ----------------------------------------------- include/media/rc-core.h | 4 ++ 2 files changed, 4 insertions(+), 109 deletions(-) (limited to 'include/media') diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index 86a3cf798775..14d3eb36672e 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -18,112 +18,11 @@ #include #include -struct lirc_buffer { - wait_queue_head_t wait_poll; - spinlock_t fifo_lock; - unsigned int chunk_size; - unsigned int size; /* in chunks */ - /* Using chunks instead of bytes pretends to simplify boundary checking - * And should allow for some performance fine tunning later */ - struct kfifo fifo; -}; - -static inline void lirc_buffer_clear(struct lirc_buffer *buf) -{ - unsigned long flags; - - if (kfifo_initialized(&buf->fifo)) { - spin_lock_irqsave(&buf->fifo_lock, flags); - kfifo_reset(&buf->fifo); - spin_unlock_irqrestore(&buf->fifo_lock, flags); - } else - WARN(1, "calling %s on an uninitialized lirc_buffer\n", - __func__); -} - -static inline int lirc_buffer_init(struct lirc_buffer *buf, - unsigned int chunk_size, - unsigned int size) -{ - int ret; - - init_waitqueue_head(&buf->wait_poll); - spin_lock_init(&buf->fifo_lock); - buf->chunk_size = chunk_size; - buf->size = size; - ret = kfifo_alloc(&buf->fifo, size * chunk_size, GFP_KERNEL); - - return ret; -} - -static inline void lirc_buffer_free(struct lirc_buffer *buf) -{ - if (kfifo_initialized(&buf->fifo)) { - kfifo_free(&buf->fifo); - } else - WARN(1, "calling %s on an uninitialized lirc_buffer\n", - __func__); -} - -static inline int lirc_buffer_len(struct lirc_buffer *buf) -{ - int len; - unsigned long flags; - - spin_lock_irqsave(&buf->fifo_lock, flags); - len = kfifo_len(&buf->fifo); - spin_unlock_irqrestore(&buf->fifo_lock, flags); - - return len; -} - -static inline int lirc_buffer_full(struct lirc_buffer *buf) -{ - return lirc_buffer_len(buf) == buf->size * buf->chunk_size; -} - -static inline int lirc_buffer_empty(struct lirc_buffer *buf) -{ - return !lirc_buffer_len(buf); -} - -static inline unsigned int lirc_buffer_read(struct lirc_buffer *buf, - unsigned char *dest) -{ - unsigned int ret = 0; - - if (lirc_buffer_len(buf) >= buf->chunk_size) - ret = kfifo_out_locked(&buf->fifo, dest, buf->chunk_size, - &buf->fifo_lock); - return ret; - -} - -static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, - unsigned char *orig) -{ - unsigned int ret; - - ret = kfifo_in_locked(&buf->fifo, orig, buf->chunk_size, - &buf->fifo_lock); - - return ret; -} - /** * struct lirc_dev - represents a LIRC device * * @name: used for logging * @minor: the minor device (/dev/lircX) number for the device - * @buffer_size: Number of FIFO buffers with @chunk_size size. - * Only used if @rbuf is NULL. - * @chunk_size: Size of each FIFO buffer. - * Only used if @rbuf is NULL. - * @buf: if %NULL, lirc_dev will allocate and manage the buffer, - * otherwise allocated by the caller which will - * have to write to the buffer by other means, like irq's - * (see also lirc_serial.c). - * @buf_internal: whether lirc_dev has allocated the read buffer or not * @rdev: &struct rc_dev associated with the device * @fops: &struct file_operations for the device * @owner: the module owning this struct @@ -137,11 +36,6 @@ struct lirc_dev { char name[40]; unsigned int minor; - unsigned int buffer_size; /* in chunks holding one code each */ - unsigned int chunk_size; - struct lirc_buffer *buf; - bool buf_internal; - struct rc_dev *rdev; const struct file_operations *fops; struct module *owner; @@ -168,7 +62,4 @@ void lirc_unregister_device(struct lirc_dev *d); */ int lirc_dev_fop_open(struct inode *inode, struct file *file); int lirc_dev_fop_close(struct inode *inode, struct file *file); -unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait); -ssize_t lirc_dev_fop_read(struct file *file, char __user *buffer, size_t length, - loff_t *ppos); #endif diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 5d6e415c7acc..fb91666bf881 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -123,6 +123,8 @@ enum rc_filter_type { * @gap_duration: duration of initial gap * @gap: true if we're in a gap * @send_timeout_reports: report timeouts in lirc raw IR. + * @rawir: queue for incoming raw IR + * @wait_poll: poll struct for lirc device * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or * LIRC_MODE_PULSE * @change_protocol: allow changing the protocol used on hardware decoders @@ -191,6 +193,8 @@ struct rc_dev { u64 gap_duration; bool gap; bool send_timeout_reports; + DECLARE_KFIFO_PTR(rawir, unsigned int); + wait_queue_head_t wait_poll; u8 send_mode; #endif int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); -- cgit From 7790e81f7e1f7f122f8fcccd91443a2571421aba Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 26 Sep 2017 07:31:29 -0400 Subject: media: lirc: move lirc_dev->attached to rc_dev->registered This is done to further remove the lirc kernel api. Ensure that every fops checks for this. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/lirc_dev.h | 2 -- include/media/rc-core.h | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include/media') diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index 14d3eb36672e..5782add67edd 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -26,7 +26,6 @@ * @rdev: &struct rc_dev associated with the device * @fops: &struct file_operations for the device * @owner: the module owning this struct - * @attached: if the device is still live * @open: open count for the device's chardev * @mutex: serialises file_operations calls * @dev: &struct device assigned to the device @@ -40,7 +39,6 @@ struct lirc_dev { const struct file_operations *fops; struct module *owner; - bool attached; int open; struct mutex mutex; /* protect from simultaneous accesses */ diff --git a/include/media/rc-core.h b/include/media/rc-core.h index fb91666bf881..b6d719734744 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -127,6 +127,8 @@ enum rc_filter_type { * @wait_poll: poll struct for lirc device * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or * LIRC_MODE_PULSE + * @registered: set to true by rc_register_device(), false by + * rc_unregister_device * @change_protocol: allow changing the protocol used on hardware decoders * @open: callback to allow drivers to enable polling/irq when IR input device * is opened. @@ -197,6 +199,7 @@ struct rc_dev { wait_queue_head_t wait_poll; u8 send_mode; #endif + bool registered; int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); int (*open)(struct rc_dev *dev); void (*close)(struct rc_dev *dev); -- cgit From 111429fb73b1f5f584d977614b87ce9e6f8361c6 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 26 Sep 2017 07:44:20 -0400 Subject: media: lirc: create rc-core open and close lirc functions Replace the generic kernel lirc api with ones which use rc-core, further reducing the lirc_dev members. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/lirc_dev.h | 11 ----------- include/media/rc-core.h | 2 ++ 2 files changed, 2 insertions(+), 11 deletions(-) (limited to 'include/media') diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index 5782add67edd..b45af81b4633 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -26,8 +26,6 @@ * @rdev: &struct rc_dev associated with the device * @fops: &struct file_operations for the device * @owner: the module owning this struct - * @open: open count for the device's chardev - * @mutex: serialises file_operations calls * @dev: &struct device assigned to the device * @cdev: &struct cdev assigned to the device */ @@ -39,10 +37,6 @@ struct lirc_dev { const struct file_operations *fops; struct module *owner; - int open; - - struct mutex mutex; /* protect from simultaneous accesses */ - struct device dev; struct cdev cdev; }; @@ -55,9 +49,4 @@ int lirc_register_device(struct lirc_dev *d); void lirc_unregister_device(struct lirc_dev *d); -/* default file operations - * used by drivers if they override only some operations - */ -int lirc_dev_fop_open(struct inode *inode, struct file *file); -int lirc_dev_fop_close(struct inode *inode, struct file *file); #endif diff --git a/include/media/rc-core.h b/include/media/rc-core.h index b6d719734744..4f585bff1347 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -117,6 +117,7 @@ enum rc_filter_type { * @rx_resolution : resolution (in ns) of input sampler * @tx_resolution: resolution (in ns) of output sampler * @lirc_dev: lirc char device + * @lirc_open: count of the number of times the device has been opened * @carrier_low: when setting the carrier range, first the low end must be * set with an ioctl and then the high end with another ioctl * @gap_start: time when gap starts @@ -190,6 +191,7 @@ struct rc_dev { u32 tx_resolution; #ifdef CONFIG_LIRC struct lirc_dev *lirc_dev; + int lirc_open; int carrier_low; ktime_t gap_start; u64 gap_duration; -- cgit From bf01c82474bf1f5c07d90a0959a95ff51374cc6f Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 26 Sep 2017 07:56:39 -0400 Subject: media: lirc: remove name from lirc_dev This is a duplicate of rcdev->driver_name. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/lirc_dev.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include/media') diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index b45af81b4633..d12e1d1c3d67 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h @@ -21,7 +21,6 @@ /** * struct lirc_dev - represents a LIRC device * - * @name: used for logging * @minor: the minor device (/dev/lircX) number for the device * @rdev: &struct rc_dev associated with the device * @fops: &struct file_operations for the device @@ -30,7 +29,6 @@ * @cdev: &struct cdev assigned to the device */ struct lirc_dev { - char name[40]; unsigned int minor; struct rc_dev *rdev; -- cgit From a6ddd4fecbb02d8ec5a865621bd2b746d585a01c Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 26 Sep 2017 09:34:47 -0400 Subject: media: lirc: remove last remnants of lirc kapi rc-core has replaced the lirc kapi many years ago, and now with the last driver ported to rc-core, we can finally remove it. Note this has no effect on userspace. All future IR drivers should use the rc-core api. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/lirc_dev.h | 50 ------------------------------------------------ include/media/rc-core.h | 8 +++++--- 2 files changed, 5 insertions(+), 53 deletions(-) delete mode 100644 include/media/lirc_dev.h (limited to 'include/media') diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h deleted file mode 100644 index d12e1d1c3d67..000000000000 --- a/include/media/lirc_dev.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * LIRC base driver - * - * by Artur Lipowski - * This code is licensed under GNU GPL - * - */ - -#ifndef _LINUX_LIRC_DEV_H -#define _LINUX_LIRC_DEV_H - -#include -#include -#include -#include -#include -#include -#include -#include - -/** - * struct lirc_dev - represents a LIRC device - * - * @minor: the minor device (/dev/lircX) number for the device - * @rdev: &struct rc_dev associated with the device - * @fops: &struct file_operations for the device - * @owner: the module owning this struct - * @dev: &struct device assigned to the device - * @cdev: &struct cdev assigned to the device - */ -struct lirc_dev { - unsigned int minor; - - struct rc_dev *rdev; - const struct file_operations *fops; - struct module *owner; - - struct device dev; - struct cdev cdev; -}; - -struct lirc_dev *lirc_allocate_device(void); - -void lirc_free_device(struct lirc_dev *d); - -int lirc_register_device(struct lirc_dev *d); - -void lirc_unregister_device(struct lirc_dev *d); - -#endif diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 4f585bff1347..2d24c88652aa 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -17,10 +17,10 @@ #define _RC_CORE #include +#include #include #include #include -#include #include extern int rc_core_debug; @@ -116,7 +116,8 @@ enum rc_filter_type { * @max_timeout: maximum timeout supported by device * @rx_resolution : resolution (in ns) of input sampler * @tx_resolution: resolution (in ns) of output sampler - * @lirc_dev: lirc char device + * @lirc_dev: lirc device + * @lirc_cdev: lirc char cdev * @lirc_open: count of the number of times the device has been opened * @carrier_low: when setting the carrier range, first the low end must be * set with an ioctl and then the high end with another ioctl @@ -190,7 +191,8 @@ struct rc_dev { u32 rx_resolution; u32 tx_resolution; #ifdef CONFIG_LIRC - struct lirc_dev *lirc_dev; + struct device lirc_dev; + struct cdev lirc_cdev; int lirc_open; int carrier_low; ktime_t gap_start; -- cgit From de142c32410649e64d44928505ffad2176a96a9e Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sat, 25 Feb 2017 06:51:32 -0500 Subject: media: lirc: implement reading scancode This implements LIRC_MODE_SCANCODE reading from the lirc device. The scancode can be read from the input device too, but with this interface you get the rc protocol, keycode, toggle and repeat status in addition to just the scancode. int main() { int fd, mode, rc; fd = open("/dev/lirc0", O_RDWR); mode = LIRC_MODE_SCANCODE; if (ioctl(fd, LIRC_SET_REC_MODE, &mode)) { // kernel too old or lirc does not support transmit } struct lirc_scancode scancode; while (read(fd, &scancode, sizeof(scancode)) == sizeof(scancode)) { printf("protocol:%d scancode:0x%x toggle:%d repeat:%d\n", scancode.rc_proto, scancode.scancode, !!(scancode.flags & LIRC_SCANCODE_FLAG_TOGGLE), !!(scancode.flags & LIRC_SCANCODE_FLAG_REPEAT)); } close(fd); } Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/rc-core.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/media') diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 2d24c88652aa..fbf1648d2ec9 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -126,9 +126,12 @@ enum rc_filter_type { * @gap: true if we're in a gap * @send_timeout_reports: report timeouts in lirc raw IR. * @rawir: queue for incoming raw IR + * @scancodes: queue for incoming decoded scancodes * @wait_poll: poll struct for lirc device * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or * LIRC_MODE_PULSE + * @rec_mode: lirc mode for receiving, either LIRC_MODE_SCANCODE or + * LIRC_MODE_MODE2 * @registered: set to true by rc_register_device(), false by * rc_unregister_device * @change_protocol: allow changing the protocol used on hardware decoders @@ -200,8 +203,10 @@ struct rc_dev { bool gap; bool send_timeout_reports; DECLARE_KFIFO_PTR(rawir, unsigned int); + DECLARE_KFIFO_PTR(scancodes, struct lirc_scancode); wait_queue_head_t wait_poll; u8 send_mode; + u8 rec_mode; #endif bool registered; int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); -- cgit From aefb5e3434db4a98f30fee460b0d8885aad0f456 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 2 Nov 2017 16:44:21 -0400 Subject: media: rc: include rather than This removes the need for include/media/lirc.h, which just includes the uapi file. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/lirc.h | 1 - 1 file changed, 1 deletion(-) delete mode 100644 include/media/lirc.h (limited to 'include/media') diff --git a/include/media/lirc.h b/include/media/lirc.h deleted file mode 100644 index 554988c860c1..000000000000 --- a/include/media/lirc.h +++ /dev/null @@ -1 +0,0 @@ -#include -- cgit From 7e45d660e4d487aa2cbeb003bd4338433feba30a Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 2 Nov 2017 17:21:13 -0400 Subject: media: lirc: allow lirc device to be opened more than once This makes it possible for lircd to read from a lirc chardev, and not keep it busy. Note that this changes the default for timeout reports to on. lircd already enables timeout reports when it opens a lirc device, leaving them on until the next reboot. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/rc-core.h | 50 ++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'include/media') diff --git a/include/media/rc-core.h b/include/media/rc-core.h index fbf1648d2ec9..3a47a25a6593 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -68,6 +68,33 @@ enum rc_filter_type { RC_FILTER_MAX }; +/** + * struct lirc_fh - represents an open lirc file + * @list: list of open file handles + * @rc: rcdev for this lirc chardev + * @carrier_low: when setting the carrier range, first the low end must be + * set with an ioctl and then the high end with another ioctl + * @send_timeout_reports: report timeouts in lirc raw IR. + * @rawir: queue for incoming raw IR + * @scancodes: queue for incoming decoded scancodes + * @wait_poll: poll struct for lirc device + * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or + * LIRC_MODE_PULSE + * @rec_mode: lirc mode for receiving, either LIRC_MODE_SCANCODE or + * LIRC_MODE_MODE2 + */ +struct lirc_fh { + struct list_head list; + struct rc_dev *rc; + int carrier_low; + bool send_timeout_reports; + DECLARE_KFIFO_PTR(rawir, unsigned int); + DECLARE_KFIFO_PTR(scancodes, struct lirc_scancode); + wait_queue_head_t wait_poll; + u8 send_mode; + u8 rec_mode; +}; + /** * struct rc_dev - represents a remote control device * @dev: driver model's view of this device @@ -118,20 +145,11 @@ enum rc_filter_type { * @tx_resolution: resolution (in ns) of output sampler * @lirc_dev: lirc device * @lirc_cdev: lirc char cdev - * @lirc_open: count of the number of times the device has been opened - * @carrier_low: when setting the carrier range, first the low end must be - * set with an ioctl and then the high end with another ioctl * @gap_start: time when gap starts * @gap_duration: duration of initial gap * @gap: true if we're in a gap - * @send_timeout_reports: report timeouts in lirc raw IR. - * @rawir: queue for incoming raw IR - * @scancodes: queue for incoming decoded scancodes - * @wait_poll: poll struct for lirc device - * @send_mode: lirc mode for sending, either LIRC_MODE_SCANCODE or - * LIRC_MODE_PULSE - * @rec_mode: lirc mode for receiving, either LIRC_MODE_SCANCODE or - * LIRC_MODE_MODE2 + * @lirc_fh_lock: protects lirc_fh list + * @lirc_fh: list of open files * @registered: set to true by rc_register_device(), false by * rc_unregister_device * @change_protocol: allow changing the protocol used on hardware decoders @@ -196,17 +214,11 @@ struct rc_dev { #ifdef CONFIG_LIRC struct device lirc_dev; struct cdev lirc_cdev; - int lirc_open; - int carrier_low; ktime_t gap_start; u64 gap_duration; bool gap; - bool send_timeout_reports; - DECLARE_KFIFO_PTR(rawir, unsigned int); - DECLARE_KFIFO_PTR(scancodes, struct lirc_scancode); - wait_queue_head_t wait_poll; - u8 send_mode; - u8 rec_mode; + spinlock_t lirc_fh_lock; + struct list_head lirc_fh; #endif bool registered; int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto); -- cgit From 57c642cb45d6f7d0d950c3bc67439989062ac743 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 23 Nov 2017 17:37:10 -0500 Subject: media: cec: move cec autorepeat handling to rc-core CEC autorepeat is different than other protocols. Autorepeat is triggered by the first repeated user control pressed CEC message, rather than a fixed REP_DELAY. This change also does away with the KEY_UP event directly after the first KEY_DOWN event, which was used to stop autorepeat from starting. See commit a9a249a2c997 ("media: cec: fix remote control passthrough") for the original change. Acked-by: Hans Verkuil Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/cec.h | 5 ----- include/media/rc-core.h | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'include/media') diff --git a/include/media/cec.h b/include/media/cec.h index 1c6a797cb6d4..7cdf71d7125a 100644 --- a/include/media/cec.h +++ b/include/media/cec.h @@ -192,11 +192,6 @@ struct cec_adapter { u32 tx_timeouts; -#ifdef CONFIG_MEDIA_CEC_RC - bool rc_repeating; - int rc_last_scancode; - u64 rc_last_keypress; -#endif #ifdef CONFIG_CEC_NOTIFIER struct cec_notifier *notifier; #endif diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 3a47a25a6593..0a4026cf64f3 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -134,6 +134,8 @@ struct lirc_fh { * @keypressed: whether a key is currently pressed * @keyup_jiffies: time (in jiffies) when the current keypress should be released * @timer_keyup: timer for releasing a keypress + * @timer_repeat: timer for autorepeat events. This is needed for CEC, which + * has non-standard repeats. * @last_keycode: keycode of last keypress * @last_protocol: protocol of last keypress * @last_scancode: scancode of last keypress @@ -202,6 +204,7 @@ struct rc_dev { bool keypressed; unsigned long keyup_jiffies; struct timer_list timer_keyup; + struct timer_list timer_repeat; u32 last_keycode; enum rc_proto last_protocol; u32 last_scancode; -- cgit From 8030e774e209bca8504e7b73e186afe8e83e1532 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 21 Sep 2017 09:36:54 -0400 Subject: media: tuner-types: add kernel-doc markups for struct tunertype This struct is lacking documentation. Add it. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/tuner-types.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/media') diff --git a/include/media/tuner-types.h b/include/media/tuner-types.h index 78f0654d9c3d..df76ac8e658c 100644 --- a/include/media/tuner-types.h +++ b/include/media/tuner-types.h @@ -171,6 +171,21 @@ struct tuner_params { struct tuner_range *ranges; }; +/** + * struct tunertype - describes the known tuners. + * + * @name: string with the tuner's name. + * @count: size of &struct tuner_params array. + * @params: pointer to &struct tuner_params array. + * + * @min: minimal tuner frequency, in 62.5 kHz step. + * should be multiplied to 16 to convert to MHz. + * @max: minimal tuner frequency, in 62.5 kHz step. + * Should be multiplied to 16 to convert to MHz. + * @stepsize: frequency step, in Hz. + * @initdata: optional byte sequence to initialize the tuner. + * @sleepdata: optional byte sequence to power down the tuner. + */ struct tunertype { char *name; unsigned int count; -- cgit From 01154ef5820a756283686247405a599c4ef7dc48 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 21 Sep 2017 10:04:30 -0400 Subject: media: v4l2-common: get rid of v4l2_routing dead struct This struct is not used anymore. Get rid of it and update the documentation about what should still be converted. Acked-by: Sakari Ailus Acked-by: Laurent Pinchart Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-common.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index aac8b7b6e691..7dbecbe3009c 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -224,10 +224,11 @@ void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi, /* ------------------------------------------------------------------------- */ -/* Note: these remaining ioctls/structs should be removed as well, but they are - still used in tuner-simple.c (TUNER_SET_CONFIG), cx18/ivtv (RESET) and - v4l2-int-device.h (v4l2_routing). To remove these ioctls some more cleanup - is needed in those modules. */ +/* + * FIXME: these remaining ioctls/structs should be removed as well, but they + * are still used in tuner-simple.c (TUNER_SET_CONFIG) and cx18/ivtv (RESET). + * To remove these ioctls some more cleanup is needed in those modules. + */ /* s_config */ struct v4l2_priv_tun_config { @@ -238,11 +239,6 @@ struct v4l2_priv_tun_config { #define VIDIOC_INT_RESET _IOW ('d', 102, u32) -struct v4l2_routing { - u32 input; - u32 output; -}; - /* ------------------------------------------------------------------------- */ /* Miscellaneous helper functions */ -- cgit From 0545629e50af60e7afad9d6023a546aed1081a8e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 22 Sep 2017 09:49:27 -0400 Subject: media: v4l2-common: get rid of struct v4l2_discrete_probe This struct is there just two store two arguments of v4l2_find_nearest_format(). The other two arguments are passed as parameter. IMHO, there isn't much sense on doing that, and that will just add one more struct to document ;) So, let's get rid of the struct, passing the parameters directly. Acked-by: Sakari Ailus Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-common.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index 7dbecbe3009c..835164f45038 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -249,14 +249,10 @@ void v4l_bound_align_image(unsigned int *w, unsigned int wmin, unsigned int hmax, unsigned int halign, unsigned int salign); -struct v4l2_discrete_probe { - const struct v4l2_frmsize_discrete *sizes; - int num_sizes; -}; - -const struct v4l2_frmsize_discrete *v4l2_find_nearest_format( - const struct v4l2_discrete_probe *probe, - s32 width, s32 height); +const struct v4l2_frmsize_discrete * +v4l2_find_nearest_format(const struct v4l2_frmsize_discrete *sizes, + const size_t num_sizes, + s32 width, s32 height); void v4l2_get_timestamp(struct timeval *tv); -- cgit From 76a59fe77022cb01df8b866d09f23c37e9af8924 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 22 Sep 2017 09:03:54 -0400 Subject: media: v4l2-common.h: document helper functions There are several helper functions that aren't documented. Document them. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-common.h | 107 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 96 insertions(+), 11 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index 835164f45038..f420c45f7915 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -28,7 +28,7 @@ #include -/* Common printk constucts for v4l-i2c drivers. These macros create a unique +/* Common printk constructs for v4l-i2c drivers. These macros create a unique prefix consisting of the driver name, the adapter number and the i2c address. */ #define v4l_printk(level, name, adapter, addr, fmt, arg...) \ @@ -174,17 +174,43 @@ void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, */ unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd); +/** + * enum v4l2_i2c_tuner_type - specifies the range of tuner address that + * should be used when seeking for I2C devices. + * + * @ADDRS_RADIO: Radio tuner addresses. + * Represent the following I2C addresses: + * 0x10 (if compiled with tea5761 support) + * and 0x60. + * @ADDRS_DEMOD: Demod tuner addresses. + * Represent the following I2C addresses: + * 0x42, 0x43, 0x4a and 0x4b. + * @ADDRS_TV: TV tuner addresses. + * Represent the following I2C addresses: + * 0x42, 0x43, 0x4a, 0x4b, 0x60, 0x61, 0x62, + * 0x63 and 0x64. + * @ADDRS_TV_WITH_DEMOD: TV tuner addresses if demod is present, this + * excludes addresses used by the demodulator + * from the list of candidates. + * Represent the following I2C addresses: + * 0x60, 0x61, 0x62, 0x63 and 0x64. + * + * NOTE: All I2C addresses above use the 7-bit notation. + */ enum v4l2_i2c_tuner_type { - ADDRS_RADIO, /* Radio tuner addresses */ - ADDRS_DEMOD, /* Demod tuner addresses */ - ADDRS_TV, /* TV tuner addresses */ - /* TV tuner addresses if demod is present, this excludes - addresses used by the demodulator from the list of - candidates. */ + ADDRS_RADIO, + ADDRS_DEMOD, + ADDRS_TV, ADDRS_TV_WITH_DEMOD, }; -/* Return a list of I2C tuner addresses to probe. Use only if the tuner - addresses are unknown. */ +/** + * v4l2_i2c_tuner_addrs - Return a list of I2C tuner addresses to probe. + * + * @type: type of the tuner to seek, as defined by + * &enum v4l2_i2c_tuner_type. + * + * NOTE: Use only if the tuner addresses are unknown. + */ const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type); /* ------------------------------------------------------------------------- */ @@ -228,6 +254,9 @@ void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi, * FIXME: these remaining ioctls/structs should be removed as well, but they * are still used in tuner-simple.c (TUNER_SET_CONFIG) and cx18/ivtv (RESET). * To remove these ioctls some more cleanup is needed in those modules. + * + * It doesn't make much sense on documenting them, as what we really want is + * to get rid of them. */ /* s_config */ @@ -243,17 +272,73 @@ struct v4l2_priv_tun_config { /* Miscellaneous helper functions */ -void v4l_bound_align_image(unsigned int *w, unsigned int wmin, +/** + * v4l_bound_align_image - adjust video dimensions according to + * a given constraints. + * + * @width: pointer to width that will be adjusted if needed. + * @wmin: minimum width. + * @wmax: maximum width. + * @walign: least significant bit on width. + * @height: pointer to height that will be adjusted if needed. + * @hmin: minimum height. + * @hmax: maximum height. + * @halign: least significant bit on width. + * @salign: least significant bit for the image size (e. g. + * :math:`width * height`). + * + * Clip an image to have @width between @wmin and @wmax, and @height between + * @hmin and @hmax, inclusive. + * + * Additionally, the @width will be a multiple of :math:`2^{walign}`, + * the @height will be a multiple of :math:`2^{halign}`, and the overall + * size :math:`width * height` will be a multiple of :math:`2^{salign}`. + * + * .. note:: + * + * #. The clipping rectangle may be shrunk or enlarged to fit the alignment + * constraints. + * #. @wmax must not be smaller than @wmin. + * #. @hmax must not be smaller than @hmin. + * #. The alignments must not be so high there are no possible image + * sizes within the allowed bounds. + * #. @wmin and @hmin must be at least 1 (don't use 0). + * #. For @walign, @halign and @salign, if you don't care about a certain + * alignment, specify ``0``, as :math:`2^0 = 1` and one byte alignment + * is equivalent to no alignment. + * #. If you only want to adjust downward, specify a maximum that's the + * same as the initial value. + */ +void v4l_bound_align_image(unsigned int *width, unsigned int wmin, unsigned int wmax, unsigned int walign, - unsigned int *h, unsigned int hmin, + unsigned int *height, unsigned int hmin, unsigned int hmax, unsigned int halign, unsigned int salign); +/** + * v4l2_find_nearest_format - find the nearest format size among a discrete + * set of resolutions. + * + * @sizes: array of &struct v4l2_frmsize_discrete image sizes. + * @num_sizes: length of @sizes array. + * @width: desired width. + * @height: desired height. + * + * Finds the closest resolution to minimize the width and height differences + * between what requested and the supported resolutions. + */ const struct v4l2_frmsize_discrete * v4l2_find_nearest_format(const struct v4l2_frmsize_discrete *sizes, const size_t num_sizes, s32 width, s32 height); +/** + * v4l2_get_timestamp - helper routine to get a timestamp to be used when + * filling streaming metadata. Internally, it uses ktime_get_ts(), + * which is the recommended way to get it. + * + * @tv: pointer to &struct timeval to be filled. + */ void v4l2_get_timestamp(struct timeval *tv); #endif /* V4L2_COMMON_H_ */ -- cgit From 4ffbf14369a6efd9e2a091fa4c6df3166b8be1dd Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 22 Sep 2017 12:52:43 -0400 Subject: media: v4l2-dv-timings.h: convert comment into kernel-doc markup The can_reduce_fps() is already documented, but it is not using the kernel-doc markup. Convert it, in order to generate documentation from it. Acked-by: Sakari Ailus Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-dv-timings.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-dv-timings.h b/include/media/v4l2-dv-timings.h index 61a18893e004..ebf00e07a515 100644 --- a/include/media/v4l2-dv-timings.h +++ b/include/media/v4l2-dv-timings.h @@ -203,13 +203,15 @@ struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait); */ struct v4l2_fract v4l2_dv_timings_aspect_ratio(const struct v4l2_dv_timings *t); -/* - * reduce_fps - check if conditions for reduced fps are true. - * bt - v4l2 timing structure - * For different timings reduced fps is allowed if following conditions - * are met - - * For CVT timings: if reduced blanking v2 (vsync == 8) is true. - * For CEA861 timings: if V4L2_DV_FL_CAN_REDUCE_FPS flag is true. +/** + * can_reduce_fps - check if conditions for reduced fps are true. + * @bt: v4l2 timing structure + * + * For different timings reduced fps is allowed if the following conditions + * are met: + * + * - For CVT timings: if reduced blanking v2 (vsync == 8) is true. + * - For CEA861 timings: if %V4L2_DV_FL_CAN_REDUCE_FPS flag is true. */ static inline bool can_reduce_fps(struct v4l2_bt_timings *bt) { -- cgit From f4ab70e3d241f70b9ad43efa8898cbddfe7a6bc5 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 24 Sep 2017 05:24:58 -0400 Subject: media: rc-core.h: minor adjustments at rc_driver_type doc The description of this enum doesn't match what it actually represents. Adjust it. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/rc-core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/media') diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 0a4026cf64f3..aed4272d47f5 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -31,9 +31,9 @@ do { \ } while (0) /** - * enum rc_driver_type - type of the RC output + * enum rc_driver_type - type of the RC driver. * - * @RC_DRIVER_SCANCODE: Driver or hardware generates a scancode + * @RC_DRIVER_SCANCODE: Driver or hardware generates a scancode. * @RC_DRIVER_IR_RAW: Driver or hardware generates pulse/space sequences. * It needs a Infra-Red pulse/space decoder * @RC_DRIVER_IR_RAW_TX: Device transmitter only, -- cgit From d63a9ef2415c4e518d9db1a1ffad014830b12c96 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 27 Sep 2017 09:51:06 -0400 Subject: media: v4l2-fwnode.h: better describe bus union at fwnode endpoint struct Better document the bus union at struct v4l2_fwnode_endpoint. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-fwnode.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index b5b465677d28..c228ec1c77cf 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -81,7 +81,17 @@ struct v4l2_fwnode_bus_mipi_csi1 { * struct v4l2_fwnode_endpoint - the endpoint data structure * @base: fwnode endpoint of the v4l2_fwnode * @bus_type: bus type - * @bus: bus configuration data structure + * @bus: union with bus configuration data structure + * @bus.parallel: embedded &struct v4l2_fwnode_bus_parallel. + * Used if the bus is parallel. + * @bus.mipi_csi1: embedded &struct v4l2_fwnode_bus_mipi_csi1. + * Used if the bus is MIPI Alliance's Camera Serial + * Interface version 1 (MIPI CSI1) or Standard + * Mobile Imaging Architecture's Compact Camera Port 2 + * (SMIA CCP2). + * @bus.mipi_csi2: embedded &struct v4l2_fwnode_bus_mipi_csi2. + * Used if the bus is MIPI Alliance's Camera Serial + * Interface version 2 (MIPI CSI2). * @link_frequencies: array of supported link frequencies * @nr_of_link_frequencies: number of elements in link_frequenccies array */ -- cgit From 20139f1857c1a156e1f61c1e66986fc409724e26 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 27 Sep 2017 12:25:21 -0400 Subject: media: v4l2-ctrls: document nested members of structs There are a few nested members at v4l2-ctrls.h. Now that kernel-doc supports, document them. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-ctrls.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index dacfe54057f8..5ccf5019408a 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -166,8 +166,15 @@ typedef void (*v4l2_ctrl_notify_fnc)(struct v4l2_ctrl *ctrl, void *priv); * empty strings ("") correspond to non-existing menu items (this * is in addition to the menu_skip_mask above). The last entry * must be NULL. + * Used only if the @type is %V4L2_CTRL_TYPE_MENU. + * @qmenu_int: A 64-bit integer array for with integer menu items. + * The size of array must be equal to the menu size, e. g.: + * :math:`ceil(\frac{maximum - minimum}{step}) + 1`. + * Used only if the @type is %V4L2_CTRL_TYPE_INTEGER_MENU. * @flags: The control's flags. - * @cur: The control's current value. + * @cur: Structure to store the current value. + * @cur.val: The control's current value, if the @type is represented via + * a u32 integer (see &enum v4l2_ctrl_type). * @val: The control's new s32 value. * @priv: The control's private pointer. For use by the driver. It is * untouched by the control framework. Note that this pointer is -- cgit From 60e7926b9376d3140022b8962c15e73e1f1e9ffa Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 27 Sep 2017 15:49:45 -0400 Subject: media: videobuf2-core: improve kernel-doc markups Now that nested structs are supported, change the documentation to use it. While here, add cross-references where pertinent and use monotonic fonts where pertinent, using the right markup tags. Acked-by: Sakari Ailus Acked-by: Marek Szyprowski Signed-off-by: Mauro Carvalho Chehab --- include/media/videobuf2-core.h | 59 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 30 deletions(-) (limited to 'include/media') diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index ef9b64398c8c..5f4df060affb 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -69,7 +69,7 @@ struct vb2_threadio_data; * argument to other ops in this structure. * @put_userptr: inform the allocator that a USERPTR buffer will no longer * be used. - * @attach_dmabuf: attach a shared struct dma_buf for a hardware operation; + * @attach_dmabuf: attach a shared &struct dma_buf for a hardware operation; * used for DMABUF memory types; dev is the alloc device * dbuf is the shared dma_buf; returns ERR_PTR() on failure; * allocator private per-buffer structure on success; @@ -153,20 +153,19 @@ struct vb2_mem_ops { * @length: size of this plane (NOT the payload) in bytes * @min_length: minimum required size of this plane (NOT the payload) in bytes. * @length is always greater or equal to @min_length. - * @offset: when memory in the associated struct vb2_buffer is - * VB2_MEMORY_MMAP, equals the offset from the start of + * @m: Union with memtype-specific data + * @m.offset: when memory in the associated struct vb2_buffer is + * %VB2_MEMORY_MMAP, equals the offset from the start of * the device memory for this plane (or is a "cookie" that * should be passed to mmap() called on the video node) - * @userptr: when memory is VB2_MEMORY_USERPTR, a userspace pointer + * @m.userptr: when memory is %VB2_MEMORY_USERPTR, a userspace pointer * pointing to this plane - * @fd: when memory is VB2_MEMORY_DMABUF, a userspace file + * @m.fd: when memory is %VB2_MEMORY_DMABUF, a userspace file * descriptor associated with this plane - * @m: Union with memtype-specific data (@offset, @userptr or - * @fd). * @data_offset: offset in the plane to the start of data; usually 0, * unless there is a header in front of the data * Should contain enough information to be able to cover all the fields - * of struct v4l2_plane at videodev2.h + * of &struct v4l2_plane at videodev2.h */ struct vb2_plane { void *mem_priv; @@ -356,7 +355,7 @@ struct vb2_buffer { * driver can return an error if hardware fails, in that * case all buffers that have been already given by * the @buf_queue callback are to be returned by the driver - * by calling vb2_buffer_done() with %VB2_BUF_STATE_QUEUED. + * by calling vb2_buffer_done() with %%VB2_BUF_STATE_QUEUED. * If you need a minimum number of buffers before you can * start streaming, then set @min_buffers_needed in the * vb2_queue structure. If that is non-zero then @@ -366,7 +365,7 @@ struct vb2_buffer { * should stop any DMA transactions or wait until they * finish and give back all buffers it got from &buf_queue * callback by calling vb2_buffer_done() with either - * %VB2_BUF_STATE_DONE or %VB2_BUF_STATE_ERROR; may use + * %VB2_BUF_STATE_DONE or %%VB2_BUF_STATE_ERROR; may use * vb2_wait_for_all_buffers() function * @buf_queue: passes buffer vb to the driver; driver may start * hardware operation on this buffer; driver should give @@ -401,13 +400,13 @@ struct vb2_ops { * @verify_planes_array: Verify that a given user space structure contains * enough planes for the buffer. This is called * for each dequeued buffer. - * @fill_user_buffer: given a vb2_buffer fill in the userspace structure. + * @fill_user_buffer: given a &vb2_buffer fill in the userspace structure. * For V4L2 this is a struct v4l2_buffer. - * @fill_vb2_buffer: given a userspace structure, fill in the vb2_buffer. + * @fill_vb2_buffer: given a userspace structure, fill in the &vb2_buffer. * If the userspace structure is invalid, then this op * will return an error. * @copy_timestamp: copy the timestamp from a userspace structure to - * the vb2_buffer struct. + * the &vb2_buffer struct. */ struct vb2_buf_ops { int (*verify_planes_array)(struct vb2_buffer *vb, const void *pb); @@ -428,10 +427,10 @@ struct vb2_buf_ops { * doesn't fill in the @alloc_devs array. * @dma_attrs: DMA attributes to use for the DMA. * @bidirectional: when this flag is set the DMA direction for the buffers of - * this queue will be overridden with DMA_BIDIRECTIONAL direction. + * this queue will be overridden with %DMA_BIDIRECTIONAL direction. * This is useful in cases where the hardware (firmware) writes to - * a buffer which is mapped as read (DMA_TO_DEVICE), or reads from - * buffer which is mapped for write (DMA_FROM_DEVICE) in order + * a buffer which is mapped as read (%DMA_TO_DEVICE), or reads from + * buffer which is mapped for write (%DMA_FROM_DEVICE) in order * to satisfy some internal hardware restrictions or adds a padding * needed by the processing algorithm. In case the DMA mapping is * not bidirectional but the hardware (firmware) trying to access @@ -440,10 +439,10 @@ struct vb2_buf_ops { * @fileio_read_once: report EOF after reading the first buffer * @fileio_write_immediately: queue buffer after each write() call * @allow_zero_bytesused: allow bytesused == 0 to be passed to the driver - * @quirk_poll_must_check_waiting_for_buffers: Return POLLERR at poll when QBUF + * @quirk_poll_must_check_waiting_for_buffers: Return %POLLERR at poll when QBUF * has not been called. This is a vb1 idiom that has been adopted * also by vb2. - * @lock: pointer to a mutex that protects the vb2_queue struct. The + * @lock: pointer to a mutex that protects the &vb2_queue struct. The * driver can set this to a mutex to let the v4l2 core serialize * the queuing ioctls. If the driver wants to handle locking * itself, then this should be set to NULL. This lock is not used @@ -464,7 +463,7 @@ struct vb2_buf_ops { * @timestamp_flags: Timestamp flags; V4L2_BUF_FLAG_TIMESTAMP_* and * V4L2_BUF_FLAG_TSTAMP_SRC_* * @gfp_flags: additional gfp flags used when allocating the buffers. - * Typically this is 0, but it may be e.g. GFP_DMA or __GFP_DMA32 + * Typically this is 0, but it may be e.g. %GFP_DMA or %__GFP_DMA32 * to force the buffer allocation to a specific memory zone. * @min_buffers_needed: the minimum number of buffers needed before * @start_streaming can be called. Used when a DMA engine @@ -491,13 +490,13 @@ struct vb2_buf_ops { * @error: a fatal error occurred on the queue * @waiting_for_buffers: used in poll() to check if vb2 is still waiting for * buffers. Only set for capture queues if qbuf has not yet been - * called since poll() needs to return POLLERR in that situation. + * called since poll() needs to return %POLLERR in that situation. * @is_multiplanar: set if buffer type is multiplanar * @is_output: set if buffer type is output * @copy_timestamp: set if vb2-core should set timestamps * @last_buffer_dequeued: used in poll() and DQBUF to immediately return if the * last decoded buffer was already dequeued. Set for capture queues - * when a buffer with the V4L2_BUF_FLAG_LAST is dequeued. + * when a buffer with the %V4L2_BUF_FLAG_LAST is dequeued. * @fileio: file io emulator internal data, used only if emulator is active * @threadio: thread io internal data, used only if thread is active */ @@ -569,7 +568,7 @@ struct vb2_queue { /** * vb2_plane_vaddr() - Return a kernel virtual address of a given plane - * @vb: vb2_buffer to which the plane in question belongs to + * @vb: &vb2_buffer to which the plane in question belongs to * @plane_no: plane number for which the address is to be returned * * This function returns a kernel virtual address of a given plane if @@ -579,7 +578,7 @@ void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no); /** * vb2_plane_cookie() - Return allocator specific cookie for the given plane - * @vb: vb2_buffer to which the plane in question belongs to + * @vb: &vb2_buffer to which the plane in question belongs to * @plane_no: plane number for which the cookie is to be returned * * This function returns an allocator specific cookie for a given plane if @@ -644,7 +643,7 @@ int vb2_wait_for_all_buffers(struct vb2_queue *q); * @index: id number of the buffer * @pb: buffer struct passed from userspace * - * Should be called from vidioc_querybuf ioctl handler in driver. + * Should be called from &vidioc_querybuf ioctl handler in driver. * The passed buffer should have been verified. * This function fills the relevant information for the userspace. */ @@ -656,7 +655,7 @@ void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb); * @memory: memory type * @count: requested buffer count * - * Should be called from vidioc_reqbufs ioctl handler of a driver. + * Should be called from &vidioc_reqbufs ioctl handler of a driver. * * This function: * @@ -664,7 +663,7 @@ void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb); * #) sets up the queue, * #) negotiates number of buffers and planes per buffer with the driver * to be used during streaming, - * #) allocates internal buffer structures (struct vb2_buffer), according to + * #) allocates internal buffer structures (&struct vb2_buffer), according to * the agreed parameters, * #) for MMAP memory type, allocates actual video memory, using the * memory handling/allocation routines provided during queue initialization @@ -779,7 +778,7 @@ int vb2_core_streamoff(struct vb2_queue *q, unsigned int type); * @type: buffer type * @index: id number of the buffer * @plane: index of the plane to be exported, 0 for single plane queues - * @flags: flags for newly created file, currently only O_CLOEXEC is + * @flags: flags for newly created file, currently only %O_CLOEXEC is * supported, refer to manual of open syscall for more details * * The return values from this function are intended to be directly returned @@ -792,7 +791,7 @@ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type, * vb2_core_queue_init() - initialize a videobuf2 queue * @q: videobuf2 queue; this structure should be allocated in driver * - * The vb2_queue structure should be allocated by the driver. The driver is + * The &vb2_queue structure should be allocated by the driver. The driver is * responsible of clearing it's content and setting initial values for some * required entries before calling this function. * q->ops, q->mem_ops, q->type and q->io_modes are mandatory. Please refer @@ -819,8 +818,8 @@ void vb2_core_queue_release(struct vb2_queue *q); * waiting on the queue. Polling will now set POLLERR and queuing and dequeuing * buffers will return -EIO. * - * The error flag will be cleared when cancelling the queue, either from - * vb2_streamoff or vb2_queue_release. Drivers should thus not call this + * The error flag will be cleared when canceling the queue, either from + * vb2_streamoff() or vb2_queue_release(). Drivers should thus not call this * function before starting the stream, otherwise the error flag will remain set * until the queue is released when closing the device node. */ -- cgit From bd945e47998a60a3d76b6dfc2fb929b3f4f9c90f Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 27 Sep 2017 15:54:43 -0400 Subject: media: media-entity.h: add kernel-doc markups for nested structs Now that nested structs are parsed by kernel-doc, add markups to them. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/media-entity.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/media') diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 222d379960b7..d7a669058b5e 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -88,6 +88,8 @@ struct media_entity_enum { * @stack: Graph traversal stack; the stack contains information * on the path the media entities to be walked and the * links through which they were reached. + * @stack.entity: pointer to &struct media_entity at the graph. + * @stack.link: pointer to &struct list_head. * @ent_enum: Visited entities * @top: The top of the stack */ @@ -247,6 +249,9 @@ enum media_entity_type { * @pipe: Pipeline this entity belongs to. * @info: Union with devnode information. Kept just for backward * compatibility. + * @info.dev: Contains device major and minor info. + * @info.dev.major: device node major, if the device is a devnode. + * @info.dev.minor: device node minor, if the device is a devnode. * @major: Devnode major number (zero if not applicable). Kept just * for backward compatibility. * @minor: Devnode minor number (zero if not applicable). Kept just -- cgit From 66f1e6078e120d3503ce43de9715538f1122c304 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 22 Sep 2017 13:35:45 -0400 Subject: media: v4l2-event.rst: improve events description Both v4l2-event.rst and v4l2-event.h have an overview of events, but there are some inconsistencies there: - at v4l2-event, the event's ring buffer is called kevent. Its name is, instead, v4l2_kevent; - Some things are mentioned on both places (with different words), others are either on one of the files. In order to cleanup this mess, put everything at v4l2-event.rst and improve it to be a little more coherent and to have cross references. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-event.h | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h index 6741910c3a18..4e83529117f7 100644 --- a/include/media/v4l2-event.h +++ b/include/media/v4l2-event.h @@ -24,40 +24,6 @@ #include #include -/* - * Overview: - * - * Events are subscribed per-filehandle. An event specification consists of a - * type and is optionally associated with an object identified through the - * 'id' field. So an event is uniquely identified by the (type, id) tuple. - * - * The v4l2-fh struct has a list of subscribed events. The v4l2_subscribed_event - * struct is added to that list, one for every subscribed event. - * - * Each v4l2_subscribed_event struct ends with an array of v4l2_kevent structs. - * This array (ringbuffer, really) is used to store any events raised by the - * driver. The v4l2_kevent struct links into the 'available' list of the - * v4l2_fh struct so VIDIOC_DQEVENT will know which event to dequeue first. - * - * Finally, if the event subscription is associated with a particular object - * such as a V4L2 control, then that object needs to know about that as well - * so that an event can be raised by that object. So the 'node' field can - * be used to link the v4l2_subscribed_event struct into a list of that - * object. - * - * So to summarize: - * - * struct v4l2_fh has two lists: one of the subscribed events, and one of the - * pending events. - * - * struct v4l2_subscribed_event has a ringbuffer of raised (pending) events of - * that particular type. - * - * If struct v4l2_subscribed_event is associated with a specific object, then - * that object will have an internal list of struct v4l2_subscribed_event so - * it knows who subscribed an event to that object. - */ - struct v4l2_fh; struct v4l2_subdev; struct v4l2_subscribed_event; -- cgit From 69b925c5fc36d8f15377fb14a00803b017371d04 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 28 Sep 2017 09:34:54 -0400 Subject: media: v4l2-dev.h: add kernel-doc to two macros There are two macros at v4l2-dev.h that aren't documented. Document them, for completeness. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-dev.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index 28a686eb7d09..82b93e91e2eb 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h @@ -261,9 +261,21 @@ struct video_device struct mutex *lock; }; -#define media_entity_to_video_device(__e) \ - container_of(__e, struct video_device, entity) -/* dev to video-device */ +/** + * media_entity_to_video_device - Returns a &struct video_device from + * the &struct media_entity embedded on it. + * + * @entity: pointer to &struct media_entity + */ +#define media_entity_to_video_device(entity) \ + container_of(entity, struct video_device, entity) + +/** + * to_video_device - Returns a &struct video_device from the + * &struct device embedded on it. + * + * @cd: pointer to &struct device + */ #define to_video_device(cd) container_of(cd, struct video_device, dev) /** -- cgit From 716b87647fb3b685d93eb55e244845248649db69 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 28 Sep 2017 09:41:48 -0400 Subject: media: v4l2-flash-led-class.h: add kernel-doc to two helper funcs There are two helper functions at v4l2-flash-led-class.h that aren't documented. Document them. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-flash-led-class.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/media') diff --git a/include/media/v4l2-flash-led-class.h b/include/media/v4l2-flash-led-class.h index 5c1d50f78e12..0a5e4518ca11 100644 --- a/include/media/v4l2-flash-led-class.h +++ b/include/media/v4l2-flash-led-class.h @@ -91,12 +91,24 @@ struct v4l2_flash { struct v4l2_ctrl **ctrls; }; +/** + * v4l2_subdev_to_v4l2_flash - Returns a &struct v4l2_flash from the + * &struct v4l2_subdev embedded on it. + * + * @sd: pointer to &struct v4l2_subdev + */ static inline struct v4l2_flash *v4l2_subdev_to_v4l2_flash( struct v4l2_subdev *sd) { return container_of(sd, struct v4l2_flash, sd); } +/** + * v4l2_ctrl_to_v4l2_flash - Returns a &struct v4l2_flash from the + * &struct v4l2_ctrl embedded on it. + * + * @c: pointer to &struct v4l2_ctrl + */ static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c) { return container_of(c->handler, struct v4l2_flash, hdl); -- cgit From 2120961f0cd71837e889a84e93dc54b647400c4e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 28 Sep 2017 09:51:42 -0400 Subject: media: v4l2-mediabus: use BIT() macro for flags Instead of using (1 << n) for bits, use the BIT() macro, as it makes a difference from documentation point of view. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-mediabus.h | 50 ++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h index 93f8afcb7a22..e5281e1086c4 100644 --- a/include/media/v4l2-mediabus.h +++ b/include/media/v4l2-mediabus.h @@ -12,6 +12,8 @@ #define V4L2_MEDIABUS_H #include +#include + /* Parallel flags */ /* @@ -20,44 +22,44 @@ * horizontal and vertical synchronisation. In "Slave mode" the host is * providing these signals to the slave. */ -#define V4L2_MBUS_MASTER (1 << 0) -#define V4L2_MBUS_SLAVE (1 << 1) +#define V4L2_MBUS_MASTER BIT(0) +#define V4L2_MBUS_SLAVE BIT(1) /* * Signal polarity flags * Note: in BT.656 mode HSYNC, FIELD, and VSYNC are unused * V4L2_MBUS_[HV]SYNC* flags should be also used for specifying * configuration of hardware that uses [HV]REF signals */ -#define V4L2_MBUS_HSYNC_ACTIVE_HIGH (1 << 2) -#define V4L2_MBUS_HSYNC_ACTIVE_LOW (1 << 3) -#define V4L2_MBUS_VSYNC_ACTIVE_HIGH (1 << 4) -#define V4L2_MBUS_VSYNC_ACTIVE_LOW (1 << 5) -#define V4L2_MBUS_PCLK_SAMPLE_RISING (1 << 6) -#define V4L2_MBUS_PCLK_SAMPLE_FALLING (1 << 7) -#define V4L2_MBUS_DATA_ACTIVE_HIGH (1 << 8) -#define V4L2_MBUS_DATA_ACTIVE_LOW (1 << 9) +#define V4L2_MBUS_HSYNC_ACTIVE_HIGH BIT(2) +#define V4L2_MBUS_HSYNC_ACTIVE_LOW BIT(3) +#define V4L2_MBUS_VSYNC_ACTIVE_HIGH BIT(4) +#define V4L2_MBUS_VSYNC_ACTIVE_LOW BIT(5) +#define V4L2_MBUS_PCLK_SAMPLE_RISING BIT(6) +#define V4L2_MBUS_PCLK_SAMPLE_FALLING BIT(7) +#define V4L2_MBUS_DATA_ACTIVE_HIGH BIT(8) +#define V4L2_MBUS_DATA_ACTIVE_LOW BIT(9) /* FIELD = 0/1 - Field1 (odd)/Field2 (even) */ -#define V4L2_MBUS_FIELD_EVEN_HIGH (1 << 10) +#define V4L2_MBUS_FIELD_EVEN_HIGH BIT(10) /* FIELD = 1/0 - Field1 (odd)/Field2 (even) */ -#define V4L2_MBUS_FIELD_EVEN_LOW (1 << 11) +#define V4L2_MBUS_FIELD_EVEN_LOW BIT(11) /* Active state of Sync-on-green (SoG) signal, 0/1 for LOW/HIGH respectively. */ -#define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH (1 << 12) -#define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW (1 << 13) +#define V4L2_MBUS_VIDEO_SOG_ACTIVE_HIGH BIT(12) +#define V4L2_MBUS_VIDEO_SOG_ACTIVE_LOW BIT(13) /* Serial flags */ /* How many lanes the client can use */ -#define V4L2_MBUS_CSI2_1_LANE (1 << 0) -#define V4L2_MBUS_CSI2_2_LANE (1 << 1) -#define V4L2_MBUS_CSI2_3_LANE (1 << 2) -#define V4L2_MBUS_CSI2_4_LANE (1 << 3) +#define V4L2_MBUS_CSI2_1_LANE BIT(0) +#define V4L2_MBUS_CSI2_2_LANE BIT(1) +#define V4L2_MBUS_CSI2_3_LANE BIT(2) +#define V4L2_MBUS_CSI2_4_LANE BIT(3) /* On which channels it can send video data */ -#define V4L2_MBUS_CSI2_CHANNEL_0 (1 << 4) -#define V4L2_MBUS_CSI2_CHANNEL_1 (1 << 5) -#define V4L2_MBUS_CSI2_CHANNEL_2 (1 << 6) -#define V4L2_MBUS_CSI2_CHANNEL_3 (1 << 7) +#define V4L2_MBUS_CSI2_CHANNEL_0 BIT(4) +#define V4L2_MBUS_CSI2_CHANNEL_1 BIT(5) +#define V4L2_MBUS_CSI2_CHANNEL_2 BIT(6) +#define V4L2_MBUS_CSI2_CHANNEL_3 BIT(7) /* Does it support only continuous or also non-continuous clock mode */ -#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK (1 << 8) -#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK (1 << 9) +#define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK BIT(8) +#define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK BIT(9) #define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \ V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE) -- cgit From 4839c58f034ae41e2dfdd097240a69622cab4c73 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 28 Sep 2017 18:39:32 -0400 Subject: media: v4l2-dev: convert VFL_TYPE_* into an enum Using enums makes easier to document, as it can use kernel-doc markups. It also allows cross-referencing, with increases the kAPI readability. Please notice that now cx88_querycap() has to have a default for the VFL type, as there are more types than supported by the driver. Acked-By: Mike Isely Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-dev.h | 59 ++++++++++++++++++++++++------------------- include/media/v4l2-mediabus.h | 30 ++++++++++++++++++++++ 2 files changed, 63 insertions(+), 26 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index 82b93e91e2eb..ecd79332d771 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h @@ -21,13 +21,25 @@ #define VIDEO_MAJOR 81 -#define VFL_TYPE_GRABBER 0 -#define VFL_TYPE_VBI 1 -#define VFL_TYPE_RADIO 2 -#define VFL_TYPE_SUBDEV 3 -#define VFL_TYPE_SDR 4 -#define VFL_TYPE_TOUCH 5 -#define VFL_TYPE_MAX 6 +/** + * enum vfl_devnode_type - type of V4L2 device node + * + * @VFL_TYPE_GRABBER: for video input/output devices + * @VFL_TYPE_VBI: for vertical blank data (i.e. closed captions, teletext) + * @VFL_TYPE_RADIO: for radio tuners + * @VFL_TYPE_SUBDEV: for V4L2 subdevices + * @VFL_TYPE_SDR: for Software Defined Radio tuners + * @VFL_TYPE_TOUCH: for touch sensors + */ +enum vfl_devnode_type { + VFL_TYPE_GRABBER = 0, + VFL_TYPE_VBI = 1, + VFL_TYPE_RADIO = 2, + VFL_TYPE_SUBDEV = 3, + VFL_TYPE_SDR = 4, + VFL_TYPE_TOUCH = 5, +}; +#define VFL_TYPE_MAX VFL_TYPE_TOUCH /* Is this a receiver, transmitter or mem-to-mem? */ /* Ignored for VFL_TYPE_SUBDEV. */ @@ -189,7 +201,7 @@ struct v4l2_file_operations { * @prio: pointer to &struct v4l2_prio_state with device's Priority state. * If NULL, then v4l2_dev->prio will be used. * @name: video device name - * @vfl_type: V4L device type + * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type * @vfl_dir: V4L receiver, transmitter or m2m * @minor: device node 'minor'. It is set to -1 if the registration failed * @num: number of the video device node @@ -237,7 +249,7 @@ struct video_device /* device info */ char name[32]; - int vfl_type; + enum vfl_devnode_type vfl_type; int vfl_dir; int minor; u16 num; @@ -282,7 +294,7 @@ struct video_device * __video_register_device - register video4linux devices * * @vdev: struct video_device to register - * @type: type of device to register + * @type: type of device to register, as defined by &enum vfl_devnode_type * @nr: which device node number is desired: * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) * @warn_if_nr_in_use: warn if the desired device node number @@ -301,29 +313,22 @@ struct video_device * * Returns 0 on success. * - * Valid values for @type are: - * - * - %VFL_TYPE_GRABBER - A frame grabber - * - %VFL_TYPE_VBI - Vertical blank data (undecoded) - * - %VFL_TYPE_RADIO - A radio card - * - %VFL_TYPE_SUBDEV - A subdevice - * - %VFL_TYPE_SDR - Software Defined Radio - * - %VFL_TYPE_TOUCH - A touch sensor - * * .. note:: * * This function is meant to be used only inside the V4L2 core. * Drivers should use video_register_device() or * video_register_device_no_warn(). */ -int __must_check __video_register_device(struct video_device *vdev, int type, - int nr, int warn_if_nr_in_use, struct module *owner); +int __must_check __video_register_device(struct video_device *vdev, + enum vfl_devnode_type type, + int nr, int warn_if_nr_in_use, + struct module *owner); /** * video_register_device - register video4linux devices * * @vdev: struct video_device to register - * @type: type of device to register + * @type: type of device to register, as defined by &enum vfl_devnode_type * @nr: which device node number is desired: * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) * @@ -337,7 +342,8 @@ int __must_check __video_register_device(struct video_device *vdev, int type, * you video_device_release() should be called on failure. */ static inline int __must_check video_register_device(struct video_device *vdev, - int type, int nr) + enum vfl_devnode_type type, + int nr) { return __video_register_device(vdev, type, nr, 1, vdev->fops->owner); } @@ -346,7 +352,7 @@ static inline int __must_check video_register_device(struct video_device *vdev, * video_register_device_no_warn - register video4linux devices * * @vdev: struct video_device to register - * @type: type of device to register + * @type: type of device to register, as defined by &enum vfl_devnode_type * @nr: which device node number is desired: * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) * @@ -362,8 +368,9 @@ static inline int __must_check video_register_device(struct video_device *vdev, * is responsible for freeing any data. Usually that means that * you video_device_release() should be called on failure. */ -static inline int __must_check video_register_device_no_warn( - struct video_device *vdev, int type, int nr) +static inline int __must_check +video_register_device_no_warn(struct video_device *vdev, + enum vfl_devnode_type type, int nr) { return __video_register_device(vdev, type, nr, 0, vdev->fops->owner); } diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h index e5281e1086c4..4d8626c468bc 100644 --- a/include/media/v4l2-mediabus.h +++ b/include/media/v4l2-mediabus.h @@ -93,6 +93,13 @@ struct v4l2_mbus_config { unsigned int flags; }; +/** + * v4l2_fill_pix_format - Ancillary routine that fills a &struct + * v4l2_pix_format fields from a &struct v4l2_mbus_framefmt. + * + * @pix_fmt: pointer to &struct v4l2_pix_format to be filled + * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model + */ static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt, const struct v4l2_mbus_framefmt *mbus_fmt) { @@ -105,6 +112,15 @@ static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt, pix_fmt->xfer_func = mbus_fmt->xfer_func; } +/** + * v4l2_fill_pix_format - Ancillary routine that fills a &struct + * v4l2_mbus_framefmt from a &struct v4l2_pix_format and a + * data format code. + * + * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be filled + * @pix_fmt: pointer to &struct v4l2_pix_format to be used as model + * @code: data format code (from &enum v4l2_mbus_pixelcode) + */ static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt, const struct v4l2_pix_format *pix_fmt, u32 code) @@ -119,6 +135,13 @@ static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt, mbus_fmt->code = code; } +/** + * v4l2_fill_pix_format - Ancillary routine that fills a &struct + * v4l2_pix_format_mplane fields from a media bus structure. + * + * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be filled + * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model + */ static inline void v4l2_fill_pix_format_mplane( struct v4l2_pix_format_mplane *pix_mp_fmt, const struct v4l2_mbus_framefmt *mbus_fmt) @@ -132,6 +155,13 @@ static inline void v4l2_fill_pix_format_mplane( pix_mp_fmt->xfer_func = mbus_fmt->xfer_func; } +/** + * v4l2_fill_pix_format - Ancillary routine that fills a &struct + * v4l2_mbus_framefmt from a &struct v4l2_pix_format_mplane. + * + * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be filled + * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be used as model + */ static inline void v4l2_fill_mbus_format_mplane( struct v4l2_mbus_framefmt *mbus_fmt, const struct v4l2_pix_format_mplane *pix_mp_fmt) -- cgit From 39654531be4cd6f358ada4d54ea9ae01d3adff08 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 5 Oct 2017 09:49:26 -0400 Subject: media: i2c-addr.h: get rid of now unused defines Some of the previously used I2C addresses there aren't used anymore. So, get rid of them. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/i2c-addr.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include/media') diff --git a/include/media/i2c-addr.h b/include/media/i2c-addr.h index 1b6872f5e970..ce4298ca8f99 100644 --- a/include/media/i2c-addr.h +++ b/include/media/i2c-addr.h @@ -11,21 +11,14 @@ */ /* bttv address list */ -#define I2C_ADDR_TSA5522 0xc2 #define I2C_ADDR_TDA7432 0x8a #define I2C_ADDR_TDA8425 0x82 #define I2C_ADDR_TDA9840 0x84 -#define I2C_ADDR_TDA9850 0xb6 /* also used by 9855,9873 */ #define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */ #define I2C_ADDR_TDA9875 0xb0 -#define I2C_ADDR_HAUPEE 0xa0 -#define I2C_ADDR_STBEE 0xae -#define I2C_ADDR_VHX 0xc0 #define I2C_ADDR_MSP3400 0x80 #define I2C_ADDR_MSP3400_ALT 0x88 #define I2C_ADDR_TEA6300 0x80 /* also used by 6320 */ -#define I2C_ADDR_DPL3518 0x84 -#define I2C_ADDR_TDA9887 0x86 /* * i2c bus addresses for the chips supported by tvaudio.c -- cgit From 1ac051631a90b3062694c5ae6b85cf4d7699749d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 5 Oct 2017 09:56:39 -0400 Subject: media: get rid of i2c-addr.h In the past, the same I2C address were used on multiple places. After I2C rebinding changes, this is no longer needed. So, we can just get rid of this header, placing the I2C address where they belong, e. g. either at bttv driver or at tvtuner. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/i2c-addr.h | 36 ------------------------------------ include/media/i2c/tvaudio.h | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 37 deletions(-) delete mode 100644 include/media/i2c-addr.h (limited to 'include/media') diff --git a/include/media/i2c-addr.h b/include/media/i2c-addr.h deleted file mode 100644 index ce4298ca8f99..000000000000 --- a/include/media/i2c-addr.h +++ /dev/null @@ -1,36 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * V4L I2C address list - * - * - * Copyright (C) 2006 Mauro Carvalho Chehab - * Based on a previous mapping by - * Ralph Metzler (rjkm@thp.uni-koeln.de) - * Gerd Knorr - * - */ - -/* bttv address list */ -#define I2C_ADDR_TDA7432 0x8a -#define I2C_ADDR_TDA8425 0x82 -#define I2C_ADDR_TDA9840 0x84 -#define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */ -#define I2C_ADDR_TDA9875 0xb0 -#define I2C_ADDR_MSP3400 0x80 -#define I2C_ADDR_MSP3400_ALT 0x88 -#define I2C_ADDR_TEA6300 0x80 /* also used by 6320 */ - -/* - * i2c bus addresses for the chips supported by tvaudio.c - */ - -#define I2C_ADDR_TDA8425 0x82 -#define I2C_ADDR_TDA9840 0x84 /* also used by TA8874Z */ -#define I2C_ADDR_TDA985x_L 0xb4 /* also used by 9873 */ -#define I2C_ADDR_TDA985x_H 0xb6 -#define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */ - -#define I2C_ADDR_TEA6300 0x80 /* also used by 6320 */ -#define I2C_ADDR_TEA6420 0x98 - -#define I2C_ADDR_PIC16C54 0x96 /* PV951 */ diff --git a/include/media/i2c/tvaudio.h b/include/media/i2c/tvaudio.h index 1ac8184693f8..f13e1a386364 100644 --- a/include/media/i2c/tvaudio.h +++ b/include/media/i2c/tvaudio.h @@ -21,7 +21,22 @@ #ifndef _TVAUDIO_H #define _TVAUDIO_H -#include +/* + * i2c bus addresses for the chips supported by tvaudio.c + */ + +#define I2C_ADDR_TDA8425 0x82 +#define I2C_ADDR_TDA9840 0x84 +#define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */ +#define I2C_ADDR_TDA9875 0xb0 +#define I2C_ADDR_TDA8425 0x82 +#define I2C_ADDR_TDA9840 0x84 /* also used by TA8874Z */ +#define I2C_ADDR_TDA985x_L 0xb4 /* also used by 9873 */ +#define I2C_ADDR_TDA985x_H 0xb6 +#define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */ +#define I2C_ADDR_TEA6300 0x80 /* also used by 6320 */ +#define I2C_ADDR_TEA6420 0x98 +#define I2C_ADDR_PIC16C54 0x96 /* PV951 */ /* The tvaudio module accepts the following inputs: */ #define TVAUDIO_INPUT_TUNER 0 -- cgit From 468fde0b79f3c36494eea6d3d7eb20cfb8f38a50 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 5 Oct 2017 13:52:19 -0400 Subject: media: v4l2-dev: document VFL_DIR_* direction defines The V4L_DIR_* direction flags document the direction for a V4L2 device node. Convert them to enum and document. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-dev.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index ecd79332d771..ed5b513f5161 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h @@ -41,11 +41,21 @@ enum vfl_devnode_type { }; #define VFL_TYPE_MAX VFL_TYPE_TOUCH -/* Is this a receiver, transmitter or mem-to-mem? */ -/* Ignored for VFL_TYPE_SUBDEV. */ -#define VFL_DIR_RX 0 -#define VFL_DIR_TX 1 -#define VFL_DIR_M2M 2 +/** + * enum vfl_direction - Identifies if a &struct video_device corresponds + * to a receiver, a transmitter or a mem-to-mem device. + * + * @VFL_DIR_RX: device is a receiver. + * @VFL_DIR_TX: device is a transmitter. + * @VFL_DIR_M2M: device is a memory to memory device. + * + * Note: Ignored if &enum vfl_devnode_type is %VFL_TYPE_SUBDEV. + */ +enum vfl_devnode_direction { + VFL_DIR_RX, + VFL_DIR_TX, + VFL_DIR_M2M, +}; struct v4l2_ioctl_callbacks; struct video_device; @@ -250,7 +260,7 @@ struct video_device /* device info */ char name[32]; enum vfl_devnode_type vfl_type; - int vfl_dir; + enum vfl_devnode_direction vfl_dir; int minor; u16 num; unsigned long flags; -- cgit From 63b31ffd1c7614966abd2d2cf59bf33734acc60c Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 5 Oct 2017 14:05:25 -0400 Subject: media: v4l2-dev: document video_device flags Convert #defines to enums and add kernel-doc markups for V4L2 video_device flags. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-dev.h | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index ed5b513f5161..88773a67a806 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h @@ -62,12 +62,22 @@ struct video_device; struct v4l2_device; struct v4l2_ctrl_handler; -/* Flag to mark the video_device struct as registered. - Drivers can clear this flag if they want to block all future - device access. It is cleared by video_unregister_device. */ -#define V4L2_FL_REGISTERED (0) -/* file->private_data points to struct v4l2_fh */ -#define V4L2_FL_USES_V4L2_FH (1) +/** + * enum v4l2_video_device_flags - Flags used by &struct video_device + * + * @V4L2_FL_REGISTERED: + * indicates that a &struct video_device is registered. + * Drivers can clear this flag if they want to block all future + * device access. It is cleared by video_unregister_device. + * @V4L2_FL_USES_V4L2_FH: + * indicates that file->private_data points to &struct v4l2_fh. + * This flag is set by the core when v4l2_fh_init() is called. + * All new drivers should use it. + */ +enum v4l2_video_device_flags { + V4L2_FL_REGISTERED = 0, + V4L2_FL_USES_V4L2_FH = 1, +}; /* Priority helper functions */ @@ -215,7 +225,8 @@ struct v4l2_file_operations { * @vfl_dir: V4L receiver, transmitter or m2m * @minor: device node 'minor'. It is set to -1 if the registration failed * @num: number of the video device node - * @flags: video device flags. Use bitops to set/clear/test flags + * @flags: video device flags. Use bitops to set/clear/test flags. + * Contains a set of &enum v4l2_video_device_flags. * @index: attribute to differentiate multiple indices on one physical device * @fh_lock: Lock for all v4l2_fhs * @fh_list: List of &struct v4l2_fh -- cgit From 3fb558f6c3bbcc4825e9d9cbd0f8a8c02d1fca84 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 5 Oct 2017 15:14:50 -0400 Subject: media: v4l2-subdev: create cross-references for ioctls When generating Sphinx output, create cross-references for the callbacks for each ioctl. While here, fix a few wrong names for ioctls. Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-subdev.h | 65 ++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 31 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index ec399c770301..5459bcf5a423 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -140,7 +140,7 @@ struct v4l2_subdev_io_pin_config { /** * struct v4l2_subdev_core_ops - Define core ops callbacks for subdevs * - * @log_status: callback for %VIDIOC_LOG_STATUS ioctl handler code. + * @log_status: callback for VIDIOC_LOG_STATUS() ioctl handler code. * * @s_io_pin_config: configure one or more chip I/O pins for chips that * multiplex different internal signal pads out to IO pins. This function @@ -168,9 +168,9 @@ struct v4l2_subdev_io_pin_config { * @compat_ioctl32: called when a 32 bits application uses a 64 bits Kernel, * in order to fix data passed from/to userspace. * - * @g_register: callback for %VIDIOC_G_REGISTER ioctl handler code. + * @g_register: callback for VIDIOC_DBG_G_REGISTER() ioctl handler code. * - * @s_register: callback for %VIDIOC_G_REGISTER ioctl handler code. + * @s_register: callback for VIDIOC_DBG_S_REGISTER() ioctl handler code. * * @s_power: puts subdevice in power saving mode (on == 0) or normal operation * mode (on == 1). @@ -215,25 +215,25 @@ struct v4l2_subdev_core_ops { * struct v4l2_subdev_tuner_ops - Callbacks used when v4l device was opened * in radio mode. * - * @s_radio: callback for %VIDIOC_S_RADIO ioctl handler code. + * @s_radio: callback for VIDIOC_S_RADIO() ioctl handler code. * - * @s_frequency: callback for %VIDIOC_S_FREQUENCY ioctl handler code. + * @s_frequency: callback for VIDIOC_S_FREQUENCY() ioctl handler code. * - * @g_frequency: callback for %VIDIOC_G_FREQUENCY ioctl handler code. + * @g_frequency: callback for VIDIOC_G_FREQUENCY() ioctl handler code. * freq->type must be filled in. Normally done by video_ioctl2() * or the bridge driver. * - * @enum_freq_bands: callback for %VIDIOC_ENUM_FREQ_BANDS ioctl handler code. + * @enum_freq_bands: callback for VIDIOC_ENUM_FREQ_BANDS() ioctl handler code. * - * @g_tuner: callback for %VIDIOC_G_TUNER ioctl handler code. + * @g_tuner: callback for VIDIOC_G_TUNER() ioctl handler code. * - * @s_tuner: callback for %VIDIOC_S_TUNER ioctl handler code. @vt->type must be + * @s_tuner: callback for VIDIOC_S_TUNER() ioctl handler code. @vt->type must be * filled in. Normally done by video_ioctl2 or the * bridge driver. * - * @g_modulator: callback for %VIDIOC_G_MODULATOR ioctl handler code. + * @g_modulator: callback for VIDIOC_G_MODULATOR() ioctl handler code. * - * @s_modulator: callback for %VIDIOC_S_MODULATOR ioctl handler code. + * @s_modulator: callback for VIDIOC_S_MODULATOR() ioctl handler code. * * @s_type_addr: sets tuner type and its I2C addr. * @@ -332,9 +332,9 @@ struct v4l2_mbus_frame_desc { * regarding clock frequency dividers, etc. If not used, then set flags * to 0. If the frequency is not supported, then -EINVAL is returned. * - * @g_std: callback for %VIDIOC_G_STD ioctl handler code. + * @g_std: callback for VIDIOC_G_STD() ioctl handler code. * - * @s_std: callback for %VIDIOC_S_STD ioctl handler code. + * @s_std: callback for VIDIOC_S_STD() ioctl handler code. * * @s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by * video input devices. @@ -342,7 +342,7 @@ struct v4l2_mbus_frame_desc { * @g_std_output: get current standard for video OUTPUT devices. This is ignored * by video input devices. * - * @querystd: callback for %VIDIOC_QUERYSTD ioctl handler code. + * @querystd: callback for VIDIOC_QUERYSTD() ioctl handler code. * * @g_tvnorms: get &v4l2_std_id with all standards supported by the video * CAPTURE device. This is ignored by video output devices. @@ -358,13 +358,15 @@ struct v4l2_mbus_frame_desc { * * @g_pixelaspect: callback to return the pixelaspect ratio. * - * @g_parm: callback for %VIDIOC_G_PARM ioctl handler code. + * @g_parm: callback for VIDIOC_G_PARM() ioctl handler code. * - * @s_parm: callback for %VIDIOC_S_PARM ioctl handler code. + * @s_parm: callback for VIDIOC_S_PARM() ioctl handler code. * - * @g_frame_interval: callback for %VIDIOC_G_FRAMEINTERVAL ioctl handler code. + * @g_frame_interval: callback for VIDIOC_SUBDEV_G_FRAME_INTERVAL() + * ioctl handler code. * - * @s_frame_interval: callback for %VIDIOC_S_FRAMEINTERVAL ioctl handler code. + * @s_frame_interval: callback for VIDIOC_SUBDEV_S_FRAME_INTERVAL() + * ioctl handler code. * * @s_dv_timings: Set custom dv timings in the sub device. This is used * when sub device is capable of setting detailed timing information @@ -372,7 +374,7 @@ struct v4l2_mbus_frame_desc { * * @g_dv_timings: Get custom dv timings in the sub device. * - * @query_dv_timings: callback for %VIDIOC_QUERY_DV_TIMINGS ioctl handler code. + * @query_dv_timings: callback for VIDIOC_QUERY_DV_TIMINGS() ioctl handler code. * * @g_mbus_config: get supported mediabus configurations * @@ -443,7 +445,8 @@ struct v4l2_subdev_video_ops { * member (to determine whether CC data from the first or second field * should be obtained). * - * @g_sliced_vbi_cap: callback for %VIDIOC_SLICED_VBI_CAP ioctl handler code. + * @g_sliced_vbi_cap: callback for VIDIOC_G_SLICED_VBI_CAP() ioctl handler + * code. * * @s_raw_fmt: setup the video encoder/decoder for raw VBI. * @@ -610,30 +613,30 @@ struct v4l2_subdev_pad_config { * struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations * * @init_cfg: initialize the pad config to default values - * @enum_mbus_code: callback for %VIDIOC_SUBDEV_ENUM_MBUS_CODE ioctl handler + * @enum_mbus_code: callback for VIDIOC_SUBDEV_ENUM_MBUS_CODE() ioctl handler * code. - * @enum_frame_size: callback for %VIDIOC_SUBDEV_ENUM_FRAME_SIZE ioctl handler + * @enum_frame_size: callback for VIDIOC_SUBDEV_ENUM_FRAME_SIZE() ioctl handler * code. * - * @enum_frame_interval: callback for %VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL ioctl + * @enum_frame_interval: callback for VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL() ioctl * handler code. * - * @get_fmt: callback for %VIDIOC_SUBDEV_G_FMT ioctl handler code. + * @get_fmt: callback for VIDIOC_SUBDEV_G_FMT() ioctl handler code. * - * @set_fmt: callback for %VIDIOC_SUBDEV_S_FMT ioctl handler code. + * @set_fmt: callback for VIDIOC_SUBDEV_S_FMT() ioctl handler code. * - * @get_selection: callback for %VIDIOC_SUBDEV_G_SELECTION ioctl handler code. + * @get_selection: callback for VIDIOC_SUBDEV_G_SELECTION() ioctl handler code. * - * @set_selection: callback for %VIDIOC_SUBDEV_S_SELECTION ioctl handler code. + * @set_selection: callback for VIDIOC_SUBDEV_S_SELECTION() ioctl handler code. * - * @get_edid: callback for %VIDIOC_SUBDEV_G_EDID ioctl handler code. + * @get_edid: callback for VIDIOC_SUBDEV_G_EDID() ioctl handler code. * - * @set_edid: callback for %VIDIOC_SUBDEV_S_EDID ioctl handler code. + * @set_edid: callback for VIDIOC_SUBDEV_S_EDID() ioctl handler code. * - * @dv_timings_cap: callback for %VIDIOC_SUBDEV_DV_TIMINGS_CAP ioctl handler + * @dv_timings_cap: callback for VIDIOC_SUBDEV_DV_TIMINGS_CAP() ioctl handler * code. * - * @enum_dv_timings: callback for %VIDIOC_SUBDEV_ENUM_DV_TIMINGS ioctl handler + * @enum_dv_timings: callback for VIDIOC_SUBDEV_ENUM_DV_TIMINGS() ioctl handler * code. * * @link_validate: used by the media controller code to check if the links -- cgit From 07bf9355cab2bcfa917704fb759ec07229d3037a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 6 Oct 2017 09:50:28 -0400 Subject: media: v4l2-subdev: fix description of tuner.s_radio ops The description there is completely broken and it mentions an ioctl that doesn't exist. Fix it. Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-subdev.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 5459bcf5a423..a6a9e54388e2 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -215,7 +215,10 @@ struct v4l2_subdev_core_ops { * struct v4l2_subdev_tuner_ops - Callbacks used when v4l device was opened * in radio mode. * - * @s_radio: callback for VIDIOC_S_RADIO() ioctl handler code. + * @s_radio: callback that switches the tuner to radio mode. + * drivers should explicitly call it when a tuner ops should + * operate on radio mode, before being able to handle it. + * Used on devices that have both AM/FM radio receiver and TV. * * @s_frequency: callback for VIDIOC_S_FREQUENCY() ioctl handler code. * @@ -238,6 +241,22 @@ struct v4l2_subdev_core_ops { * @s_type_addr: sets tuner type and its I2C addr. * * @s_config: sets tda9887 specific stuff, like port1, port2 and qss + * + * .. note:: + * + * On devices that have both AM/FM and TV, it is up to the driver + * to explicitly call s_radio when the tuner should be switched to + * radio mode, before handling other &struct v4l2_subdev_tuner_ops + * that would require it. An example of such usage is:: + * + * static void s_frequency(void *priv, const struct v4l2_frequency *f) + * { + * ... + * if (f.type == V4L2_TUNER_RADIO) + * v4l2_device_call_all(v4l2_dev, 0, tuner, s_radio); + * ... + * v4l2_device_call_all(v4l2_dev, 0, tuner, s_frequency); + * } */ struct v4l2_subdev_tuner_ops { int (*s_radio)(struct v4l2_subdev *sd); -- cgit From 37bc2d87419832ead83e480845615d328d199633 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 6 Oct 2017 12:20:52 -0400 Subject: media: vb2-core: use bitops for bits Use the existing macros to identify vb2_io_modes bits. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/videobuf2-core.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'include/media') diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 5f4df060affb..0308d8439049 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -16,6 +16,7 @@ #include #include #include +#include #define VB2_MAX_FRAME (32) #define VB2_MAX_PLANES (8) @@ -191,11 +192,11 @@ struct vb2_plane { * @VB2_DMABUF: driver supports DMABUF with streaming API */ enum vb2_io_modes { - VB2_MMAP = (1 << 0), - VB2_USERPTR = (1 << 1), - VB2_READ = (1 << 2), - VB2_WRITE = (1 << 3), - VB2_DMABUF = (1 << 4), + VB2_MMAP = BIT(0), + VB2_USERPTR = BIT(1), + VB2_READ = BIT(2), + VB2_WRITE = BIT(3), + VB2_DMABUF = BIT(4), }; /** -- cgit From 2b1413245550397d309c619cfc0ef0fa193522e4 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 6 Oct 2017 12:22:43 -0400 Subject: media: vb2-core: Improve kernel-doc markups There are several issues on the current markups: - lack of cross-references; - wrong cross-references; - lack of a period of the end of several phrases; - Some descriptions can be enhanced. Signed-off-by: Mauro Carvalho Chehab --- include/media/videobuf2-core.h | 376 ++++++++++++++++++++++------------------- 1 file changed, 204 insertions(+), 172 deletions(-) (limited to 'include/media') diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 0308d8439049..e145f1475ffe 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -46,7 +46,7 @@ struct vb2_fileio_data; struct vb2_threadio_data; /** - * struct vb2_mem_ops - memory handling/memory allocator operations + * struct vb2_mem_ops - memory handling/memory allocator operations. * @alloc: allocate video memory and, optionally, allocator private data, * return ERR_PTR() on failure or a pointer to allocator private, * per-buffer data on success; the returned private structure @@ -146,27 +146,28 @@ struct vb2_mem_ops { }; /** - * struct vb2_plane - plane information - * @mem_priv: private data with this plane - * @dbuf: dma_buf - shared buffer object + * struct vb2_plane - plane information. + * @mem_priv: private data with this plane. + * @dbuf: dma_buf - shared buffer object. * @dbuf_mapped: flag to show whether dbuf is mapped or not - * @bytesused: number of bytes occupied by data in the plane (payload) - * @length: size of this plane (NOT the payload) in bytes + * @bytesused: number of bytes occupied by data in the plane (payload). + * @length: size of this plane (NOT the payload) in bytes. * @min_length: minimum required size of this plane (NOT the payload) in bytes. * @length is always greater or equal to @min_length. - * @m: Union with memtype-specific data + * @m: Union with memtype-specific data. * @m.offset: when memory in the associated struct vb2_buffer is * %VB2_MEMORY_MMAP, equals the offset from the start of * the device memory for this plane (or is a "cookie" that - * should be passed to mmap() called on the video node) + * should be passed to mmap() called on the video node). * @m.userptr: when memory is %VB2_MEMORY_USERPTR, a userspace pointer - * pointing to this plane + * pointing to this plane. * @m.fd: when memory is %VB2_MEMORY_DMABUF, a userspace file - * descriptor associated with this plane + * descriptor associated with this plane. * @data_offset: offset in the plane to the start of data; usually 0, - * unless there is a header in front of the data + * unless there is a header in front of the data. + * * Should contain enough information to be able to cover all the fields - * of &struct v4l2_plane at videodev2.h + * of &struct v4l2_plane at videodev2.h. */ struct vb2_plane { void *mem_priv; @@ -184,12 +185,12 @@ struct vb2_plane { }; /** - * enum vb2_io_modes - queue access methods - * @VB2_MMAP: driver supports MMAP with streaming API - * @VB2_USERPTR: driver supports USERPTR with streaming API - * @VB2_READ: driver supports read() style access - * @VB2_WRITE: driver supports write() style access - * @VB2_DMABUF: driver supports DMABUF with streaming API + * enum vb2_io_modes - queue access methods. + * @VB2_MMAP: driver supports MMAP with streaming API. + * @VB2_USERPTR: driver supports USERPTR with streaming API. + * @VB2_READ: driver supports read() style access. + * @VB2_WRITE: driver supports write() style access. + * @VB2_DMABUF: driver supports DMABUF with streaming API. */ enum vb2_io_modes { VB2_MMAP = BIT(0), @@ -200,19 +201,19 @@ enum vb2_io_modes { }; /** - * enum vb2_buffer_state - current video buffer state - * @VB2_BUF_STATE_DEQUEUED: buffer under userspace control - * @VB2_BUF_STATE_PREPARING: buffer is being prepared in videobuf - * @VB2_BUF_STATE_PREPARED: buffer prepared in videobuf and by the driver - * @VB2_BUF_STATE_QUEUED: buffer queued in videobuf, but not in driver - * @VB2_BUF_STATE_REQUEUEING: re-queue a buffer to the driver + * enum vb2_buffer_state - current video buffer state. + * @VB2_BUF_STATE_DEQUEUED: buffer under userspace control. + * @VB2_BUF_STATE_PREPARING: buffer is being prepared in videobuf. + * @VB2_BUF_STATE_PREPARED: buffer prepared in videobuf and by the driver. + * @VB2_BUF_STATE_QUEUED: buffer queued in videobuf, but not in driver. + * @VB2_BUF_STATE_REQUEUEING: re-queue a buffer to the driver. * @VB2_BUF_STATE_ACTIVE: buffer queued in driver and possibly used - * in a hardware operation + * in a hardware operation. * @VB2_BUF_STATE_DONE: buffer returned from driver to videobuf, but - * not yet dequeued to userspace + * not yet dequeued to userspace. * @VB2_BUF_STATE_ERROR: same as above, but the operation on the buffer * has ended with an error, which will be reported - * to the userspace when it is dequeued + * to the userspace when it is dequeued. */ enum vb2_buffer_state { VB2_BUF_STATE_DEQUEUED, @@ -228,15 +229,15 @@ enum vb2_buffer_state { struct vb2_queue; /** - * struct vb2_buffer - represents a video buffer - * @vb2_queue: the queue to which this driver belongs - * @index: id number of the buffer - * @type: buffer type - * @memory: the method, in which the actual data is passed + * struct vb2_buffer - represents a video buffer. + * @vb2_queue: pointer to &struct vb2_queue with the queue to + * which this driver belongs. + * @index: id number of the buffer. + * @type: buffer type. + * @memory: the method, in which the actual data is passed. * @num_planes: number of planes in the buffer - * on an internal driver queue - * @planes: private per-plane information; do not change - * @timestamp: frame timestamp in ns + * on an internal driver queue. + * @timestamp: frame timestamp in ns. */ struct vb2_buffer { struct vb2_queue *vb2_queue; @@ -244,7 +245,6 @@ struct vb2_buffer { unsigned int type; unsigned int memory; unsigned int num_planes; - struct vb2_plane planes[VB2_MAX_PLANES]; u64 timestamp; /* private: internal use only @@ -254,9 +254,11 @@ struct vb2_buffer { * all buffers queued from userspace * done_entry: entry on the list that stores all buffers ready * to be dequeued to userspace + * vb2_plane: per-plane information; do not change */ enum vb2_buffer_state state; + struct vb2_plane planes[VB2_MAX_PLANES]; struct list_head queued_entry; struct list_head done_entry; #ifdef CONFIG_VIDEO_ADV_DEBUG @@ -292,7 +294,7 @@ struct vb2_buffer { }; /** - * struct vb2_ops - driver-specific callbacks + * struct vb2_ops - driver-specific callbacks. * * @queue_setup: called from VIDIOC_REQBUFS() and VIDIOC_CREATE_BUFS() * handlers before memory allocation. It can be called @@ -356,17 +358,17 @@ struct vb2_buffer { * driver can return an error if hardware fails, in that * case all buffers that have been already given by * the @buf_queue callback are to be returned by the driver - * by calling vb2_buffer_done() with %%VB2_BUF_STATE_QUEUED. + * by calling vb2_buffer_done() with %VB2_BUF_STATE_QUEUED. * If you need a minimum number of buffers before you can - * start streaming, then set @min_buffers_needed in the - * vb2_queue structure. If that is non-zero then + * start streaming, then set + * &vb2_queue->min_buffers_needed. If that is non-zero then * @start_streaming won't be called until at least that * many buffers have been queued up by userspace. * @stop_streaming: called when 'streaming' state must be disabled; driver * should stop any DMA transactions or wait until they * finish and give back all buffers it got from &buf_queue * callback by calling vb2_buffer_done() with either - * %VB2_BUF_STATE_DONE or %%VB2_BUF_STATE_ERROR; may use + * %VB2_BUF_STATE_DONE or %VB2_BUF_STATE_ERROR; may use * vb2_wait_for_all_buffers() function * @buf_queue: passes buffer vb to the driver; driver may start * hardware operation on this buffer; driver should give @@ -396,18 +398,18 @@ struct vb2_ops { }; /** - * struct vb2_buf_ops - driver-specific callbacks + * struct vb2_buf_ops - driver-specific callbacks. * * @verify_planes_array: Verify that a given user space structure contains * enough planes for the buffer. This is called * for each dequeued buffer. * @fill_user_buffer: given a &vb2_buffer fill in the userspace structure. - * For V4L2 this is a struct v4l2_buffer. + * For V4L2 this is a &struct v4l2_buffer. * @fill_vb2_buffer: given a userspace structure, fill in the &vb2_buffer. * If the userspace structure is invalid, then this op * will return an error. * @copy_timestamp: copy the timestamp from a userspace structure to - * the &vb2_buffer struct. + * the &struct vb2_buffer. */ struct vb2_buf_ops { int (*verify_planes_array)(struct vb2_buffer *vb, const void *pb); @@ -418,12 +420,13 @@ struct vb2_buf_ops { }; /** - * struct vb2_queue - a videobuf queue + * struct vb2_queue - a videobuf queue. * * @type: private buffer type whose content is defined by the vb2-core * caller. For example, for V4L2, it should match - * the types defined on enum &v4l2_buf_type - * @io_modes: supported io methods (see vb2_io_modes enum) + * the types defined on &enum v4l2_buf_type. + * @io_modes: supported io methods (see &enum vb2_io_modes). + * @alloc_devs: &struct device memory type/allocator-specific per-plane device * @dev: device to use for the default allocation context if the driver * doesn't fill in the @alloc_devs array. * @dma_attrs: DMA attributes to use for the DMA. @@ -443,7 +446,7 @@ struct vb2_buf_ops { * @quirk_poll_must_check_waiting_for_buffers: Return %POLLERR at poll when QBUF * has not been called. This is a vb1 idiom that has been adopted * also by vb2. - * @lock: pointer to a mutex that protects the &vb2_queue struct. The + * @lock: pointer to a mutex that protects the &struct vb2_queue. The * driver can set this to a mutex to let the v4l2 core serialize * the queuing ioctls. If the driver wants to handle locking * itself, then this should be set to NULL. This lock is not used @@ -454,15 +457,15 @@ struct vb2_buf_ops { * drivers to easily associate an owner filehandle with the queue. * @ops: driver-specific callbacks * @mem_ops: memory allocator specific callbacks - * @buf_ops: callbacks to deliver buffer information - * between user-space and kernel-space - * @drv_priv: driver private data + * @buf_ops: callbacks to deliver buffer information. + * between user-space and kernel-space. + * @drv_priv: driver private data. * @buf_struct_size: size of the driver-specific buffer structure; * "0" indicates the driver doesn't want to use a custom buffer - * structure type. for example, sizeof(struct vb2_v4l2_buffer) + * structure type. for example, ``sizeof(struct vb2_v4l2_buffer)`` * will be used for v4l2. - * @timestamp_flags: Timestamp flags; V4L2_BUF_FLAG_TIMESTAMP_* and - * V4L2_BUF_FLAG_TSTAMP_SRC_* + * @timestamp_flags: Timestamp flags; ``V4L2_BUF_FLAG_TIMESTAMP_*`` and + * ``V4L2_BUF_FLAG_TSTAMP_SRC_*`` * @gfp_flags: additional gfp flags used when allocating the buffers. * Typically this is 0, but it may be e.g. %GFP_DMA or %__GFP_DMA32 * to force the buffer allocation to a specific memory zone. @@ -484,7 +487,6 @@ struct vb2_buf_ops { * @done_list: list of buffers ready to be dequeued to userspace * @done_lock: lock to protect done_list list * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued - * @alloc_devs: memory type/allocator-specific per-plane device * @streaming: current streaming state * @start_streaming_called: @start_streaming was called successfully and we * started streaming. @@ -525,6 +527,8 @@ struct vb2_queue { gfp_t gfp_flags; u32 min_buffers_needed; + struct device *alloc_devs[VB2_MAX_PLANES]; + /* private: internal use only */ struct mutex mmap_lock; unsigned int memory; @@ -540,8 +544,6 @@ struct vb2_queue { spinlock_t done_lock; wait_queue_head_t done_wq; - struct device *alloc_devs[VB2_MAX_PLANES]; - unsigned int streaming:1; unsigned int start_streaming_called:1; unsigned int error:1; @@ -568,9 +570,10 @@ struct vb2_queue { }; /** - * vb2_plane_vaddr() - Return a kernel virtual address of a given plane - * @vb: &vb2_buffer to which the plane in question belongs to - * @plane_no: plane number for which the address is to be returned + * vb2_plane_vaddr() - Return a kernel virtual address of a given plane. + * @vb: pointer to &struct vb2_buffer to which the plane in + * question belongs to. + * @plane_no: plane number for which the address is to be returned. * * This function returns a kernel virtual address of a given plane if * such a mapping exist, NULL otherwise. @@ -578,9 +581,10 @@ struct vb2_queue { void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no); /** - * vb2_plane_cookie() - Return allocator specific cookie for the given plane - * @vb: &vb2_buffer to which the plane in question belongs to - * @plane_no: plane number for which the cookie is to be returned + * vb2_plane_cookie() - Return allocator specific cookie for the given plane. + * @vb: pointer to &struct vb2_buffer to which the plane in + * question belongs to. + * @plane_no: plane number for which the cookie is to be returned. * * This function returns an allocator specific cookie for a given plane if * available, NULL otherwise. The allocator should provide some simple static @@ -591,9 +595,11 @@ void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no); void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no); /** - * vb2_buffer_done() - inform videobuf that an operation on a buffer is finished - * @vb: vb2_buffer returned from the driver - * @state: either %VB2_BUF_STATE_DONE if the operation finished + * vb2_buffer_done() - inform videobuf that an operation on a buffer + * is finished. + * @vb: pointer to &struct vb2_buffer to be used. + * @state: state of the buffer, as defined by &enum vb2_buffer_state. + * Either %VB2_BUF_STATE_DONE if the operation finished * successfully, %VB2_BUF_STATE_ERROR if the operation finished * with an error or %VB2_BUF_STATE_QUEUED if the driver wants to * requeue buffers. If start_streaming fails then it should return @@ -614,8 +620,8 @@ void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no); void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state); /** - * vb2_discard_done() - discard all buffers marked as DONE - * @q: videobuf2 queue + * vb2_discard_done() - discard all buffers marked as DONE. + * @q: pointer to &struct vb2_queue with videobuf2 queue. * * This function is intended to be used with suspend/resume operations. It * discards all 'done' buffers as they would be too old to be requested after @@ -628,35 +634,40 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state); void vb2_discard_done(struct vb2_queue *q); /** - * vb2_wait_for_all_buffers() - wait until all buffers are given back to vb2 - * @q: videobuf2 queue + * vb2_wait_for_all_buffers() - wait until all buffers are given back to vb2. + * @q: pointer to &struct vb2_queue with videobuf2 queue. * * This function will wait until all buffers that have been given to the driver * by &vb2_ops->buf_queue are given back to vb2 with vb2_buffer_done(). It - * doesn't call wait_prepare()/wait_finish() pair. It is intended to be called - * with all locks taken, for example from &vb2_ops->stop_streaming callback. + * doesn't call &vb2_ops->wait_prepare/&vb2_ops->wait_finish pair. + * It is intended to be called with all locks taken, for example from + * &vb2_ops->stop_streaming callback. */ int vb2_wait_for_all_buffers(struct vb2_queue *q); /** - * vb2_core_querybuf() - query video buffer information - * @q: videobuf queue - * @index: id number of the buffer - * @pb: buffer struct passed from userspace + * vb2_core_querybuf() - query video buffer information. + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @index: id number of the buffer. + * @pb: buffer struct passed from userspace. + * + * Should be called from &v4l2_ioctl_ops->vidioc_querybuf ioctl handler + * in driver. * - * Should be called from &vidioc_querybuf ioctl handler in driver. * The passed buffer should have been verified. + * * This function fills the relevant information for the userspace. */ void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb); /** - * vb2_core_reqbufs() - Initiate streaming - * @q: videobuf2 queue - * @memory: memory type - * @count: requested buffer count + * vb2_core_reqbufs() - Initiate streaming. + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @memory: memory type, as defined by &enum vb2_memory. + * @count: requested buffer count. * - * Should be called from &vidioc_reqbufs ioctl handler of a driver. + * Should be called from &v4l2_ioctl_ops->vidioc_reqbufs ioctl + * handler of a driver. * * This function: * @@ -670,32 +681,35 @@ void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb); * memory handling/allocation routines provided during queue initialization * * If req->count is 0, all the memory will be freed instead. - * If the queue has been allocated previously (by a previous vb2_reqbufs) call - * and the queue is not busy, memory will be reallocated. + * + * If the queue has been allocated previously by a previous vb2_core_reqbufs() + * call and the queue is not busy, memory will be reallocated. * * The return values from this function are intended to be directly returned - * from vidioc_reqbufs handler in driver. + * from &v4l2_ioctl_ops->vidioc_reqbufs handler in driver. */ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, unsigned int *count); /** * vb2_core_create_bufs() - Allocate buffers and any required auxiliary structs - * @q: videobuf2 queue - * @memory: memory type - * @count: requested buffer count - * @requested_planes: number of planes requested - * @requested_sizes: array with the size of the planes + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @memory: memory type, as defined by &enum vb2_memory. + * @count: requested buffer count. + * @requested_planes: number of planes requested. + * @requested_sizes: array with the size of the planes. + * + * Should be called from &v4l2_ioctl_ops->vidioc_create_bufs ioctl handler + * of a driver. * - * Should be called from VIDIOC_CREATE_BUFS() ioctl handler of a driver. * This function: * * #) verifies parameter sanity - * #) calls the .queue_setup() queue operation + * #) calls the &vb2_ops->queue_setup queue operation * #) performs any necessary memory allocations * * Return: the return values from this function are intended to be directly - * returned from VIDIOC_CREATE_BUFS() handler in driver. + * returned from &v4l2_ioctl_ops->vidioc_create_bufs handler in driver. */ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, unsigned int *count, unsigned int requested_planes, @@ -703,31 +717,34 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, /** * vb2_core_prepare_buf() - Pass ownership of a buffer from userspace - * to the kernel - * @q: videobuf2 queue - * @index: id number of the buffer - * @pb: buffer structure passed from userspace to vidioc_prepare_buf - * handler in driver + * to the kernel. + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @index: id number of the buffer. + * @pb: buffer structure passed from userspace to + * &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver. + * + * Should be called from &v4l2_ioctl_ops->vidioc_prepare_buf ioctl handler + * of a driver. * - * Should be called from vidioc_prepare_buf ioctl handler of a driver. * The passed buffer should have been verified. + * * This function calls buf_prepare callback in the driver (if provided), * in which driver-specific buffer initialization can be performed, * * The return values from this function are intended to be directly returned - * from vidioc_prepare_buf handler in driver. + * from v4l2_ioctl_ops->vidioc_prepare_buf handler in driver. */ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); /** * vb2_core_qbuf() - Queue a buffer from userspace * - * @q: videobuf2 queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. * @index: id number of the buffer - * @pb: buffer structure passed from userspace to vidioc_qbuf handler - * in driver + * @pb: buffer structure passed from userspace to + * v4l2_ioctl_ops->vidioc_qbuf handler in driver * - * Should be called from vidioc_qbuf ioctl handler of a driver. + * Should be called from v4l2_ioctl_ops->vidioc_qbuf ioctl handler of a driver. * The passed buffer should have been verified. * * This function: @@ -738,21 +755,21 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); * &vb2_ops->buf_queue callback for processing. * * The return values from this function are intended to be directly returned - * from vidioc_qbuf handler in driver. + * from v4l2_ioctl_ops->vidioc_qbuf handler in driver. */ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb); /** * vb2_core_dqbuf() - Dequeue a buffer to the userspace - * @q: videobuf2 queue + * @q: pointer to &struct vb2_queue with videobuf2 queue * @pindex: pointer to the buffer index. May be NULL - * @pb: buffer structure passed from userspace to vidioc_dqbuf handler - * in driver + * @pb: buffer structure passed from userspace to + * v4l2_ioctl_ops->vidioc_dqbuf handler in driver. * @nonblocking: if true, this call will not sleep waiting for a buffer if no * buffers ready for dequeuing are present. Normally the driver - * would be passing (file->f_flags & O_NONBLOCK) here + * would be passing (file->f_flags & O_NONBLOCK) here. * - * Should be called from vidioc_dqbuf ioctl handler of a driver. + * Should be called from v4l2_ioctl_ops->vidioc_dqbuf ioctl handler of a driver. * The passed buffer should have been verified. * * This function: @@ -764,7 +781,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb); * the userspace. * * The return values from this function are intended to be directly returned - * from vidioc_dqbuf handler in driver. + * from v4l2_ioctl_ops->vidioc_dqbuf handler in driver. */ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb, bool nonblocking); @@ -773,51 +790,57 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type); int vb2_core_streamoff(struct vb2_queue *q, unsigned int type); /** - * vb2_core_expbuf() - Export a buffer as a file descriptor - * @q: videobuf2 queue - * @fd: file descriptor associated with DMABUF (set by driver) * - * @type: buffer type - * @index: id number of the buffer + * vb2_core_expbuf() - Export a buffer as a file descriptor. + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @fd: pointer to the file descriptor associated with DMABUF + * (set by driver). + * @type: buffer type. + * @index: id number of the buffer. * @plane: index of the plane to be exported, 0 for single plane queues - * @flags: flags for newly created file, currently only %O_CLOEXEC is - * supported, refer to manual of open syscall for more details + * @flags: file flags for newly created file, as defined at + * include/uapi/asm-generic/fcntl.h. + * Currently, the only used flag is %O_CLOEXEC. + * is supported, refer to manual of open syscall for more details. * * The return values from this function are intended to be directly returned - * from vidioc_expbuf handler in driver. + * from v4l2_ioctl_ops->vidioc_expbuf handler in driver. */ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type, unsigned int index, unsigned int plane, unsigned int flags); /** * vb2_core_queue_init() - initialize a videobuf2 queue - * @q: videobuf2 queue; this structure should be allocated in driver + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * This structure should be allocated in driver * * The &vb2_queue structure should be allocated by the driver. The driver is * responsible of clearing it's content and setting initial values for some * required entries before calling this function. - * q->ops, q->mem_ops, q->type and q->io_modes are mandatory. Please refer - * to the struct vb2_queue description in include/media/videobuf2-core.h - * for more information. + * + * .. note:: + * + * The following fields at @q should be set before calling this function: + * &vb2_queue->ops, &vb2_queue->mem_ops, &vb2_queue->type. */ int vb2_core_queue_init(struct vb2_queue *q); /** * vb2_core_queue_release() - stop streaming, release the queue and free memory - * @q: videobuf2 queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. * * This function stops streaming and performs necessary clean ups, including * freeing video buffer memory. The driver is responsible for freeing - * the vb2_queue structure itself. + * the &struct vb2_queue itself. */ void vb2_core_queue_release(struct vb2_queue *q); /** * vb2_queue_error() - signal a fatal error on the queue - * @q: videobuf2 queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. * * Flag that a fatal unrecoverable error has occurred and wake up all processes - * waiting on the queue. Polling will now set POLLERR and queuing and dequeuing - * buffers will return -EIO. + * waiting on the queue. Polling will now set %POLLERR and queuing and dequeuing + * buffers will return %-EIO. * * The error flag will be cleared when canceling the queue, either from * vb2_streamoff() or vb2_queue_release(). Drivers should thus not call this @@ -827,9 +850,10 @@ void vb2_core_queue_release(struct vb2_queue *q); void vb2_queue_error(struct vb2_queue *q); /** - * vb2_mmap() - map video buffers into application address space - * @q: videobuf2 queue - * @vma: vma passed to the mmap file operation handler in the driver + * vb2_mmap() - map video buffers into application address space. + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @vma: pointer to &struct vm_area_struct with the vma passed + * to the mmap file operation handler in the driver. * * Should be called from mmap file operation handler of a driver. * This function maps one plane of one of the available video buffers to @@ -837,8 +861,10 @@ void vb2_queue_error(struct vb2_queue *q); * has to be called once per each plane per each buffer previously allocated. * * When the userspace application calls mmap, it passes to it an offset returned - * to it earlier by the means of vidioc_querybuf handler. That offset acts as - * a "cookie", which is then used to identify the plane to be mapped. + * to it earlier by the means of &v4l2_ioctl_ops->vidioc_querybuf handler. + * That offset acts as a "cookie", which is then used to identify the plane + * to be mapped. + * * This function finds a plane with a matching offset and a mapping is performed * by the means of a provided memory operation. * @@ -856,10 +882,12 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q, #endif /** - * vb2_core_poll() - implements poll userspace operation - * @q: videobuf2 queue - * @file: file argument passed to the poll file operation handler - * @wait: wait argument passed to the poll file operation handler + * vb2_core_poll() - implements poll userspace operation. + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @file: &struct file argument passed to the poll + * file operation handler. + * @wait: &poll_table wait argument passed to the poll + * file operation handler. * * This function implements poll file operation handler for a driver. * For CAPTURE queues, if a buffer is ready to be dequeued, the userspace will @@ -880,10 +908,10 @@ size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count, loff_t *ppos, int nonblock); /** - * typedef vb2_thread_fnc - callback function for use with vb2_thread + * typedef vb2_thread_fnc - callback function for use with vb2_thread. * - * @vb: pointer to struct &vb2_buffer - * @priv: pointer to a private pointer + * @vb: pointer to struct &vb2_buffer. + * @priv: pointer to a private data. * * This is called whenever a buffer is dequeued in the thread. */ @@ -891,13 +919,13 @@ typedef int (*vb2_thread_fnc)(struct vb2_buffer *vb, void *priv); /** * vb2_thread_start() - start a thread for the given queue. - * @q: videobuf queue - * @fnc: callback function - * @priv: priv pointer passed to the callback function + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @fnc: &vb2_thread_fnc callback function. + * @priv: priv pointer passed to the callback function. * @thread_name:the name of the thread. This will be prefixed with "vb2-". * * This starts a thread that will queue and dequeue until an error occurs - * or @vb2_thread_stop is called. + * or vb2_thread_stop() is called. * * .. attention:: * @@ -910,13 +938,13 @@ int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv, /** * vb2_thread_stop() - stop the thread for the given queue. - * @q: videobuf queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. */ int vb2_thread_stop(struct vb2_queue *q); /** - * vb2_is_streaming() - return streaming status of the queue - * @q: videobuf queue + * vb2_is_streaming() - return streaming status of the queue. + * @q: pointer to &struct vb2_queue with videobuf2 queue. */ static inline bool vb2_is_streaming(struct vb2_queue *q) { @@ -925,15 +953,16 @@ static inline bool vb2_is_streaming(struct vb2_queue *q) /** * vb2_fileio_is_active() - return true if fileio is active. - * @q: videobuf queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. * * This returns true if read() or write() is used to stream the data * as opposed to stream I/O. This is almost never an important distinction, * except in rare cases. One such case is that using read() or write() to - * stream a format using V4L2_FIELD_ALTERNATE is not allowed since there + * stream a format using %V4L2_FIELD_ALTERNATE is not allowed since there * is no way you can pass the field information of each buffer to/from * userspace. A driver that supports this field format should check for - * this in the queue_setup op and reject it if this function returns true. + * this in the &vb2_ops->queue_setup op and reject it if this function returns + * true. */ static inline bool vb2_fileio_is_active(struct vb2_queue *q) { @@ -941,8 +970,8 @@ static inline bool vb2_fileio_is_active(struct vb2_queue *q) } /** - * vb2_is_busy() - return busy status of the queue - * @q: videobuf queue + * vb2_is_busy() - return busy status of the queue. + * @q: pointer to &struct vb2_queue with videobuf2 queue. * * This function checks if queue has any buffers allocated. */ @@ -952,8 +981,8 @@ static inline bool vb2_is_busy(struct vb2_queue *q) } /** - * vb2_get_drv_priv() - return driver private data associated with the queue - * @q: videobuf queue + * vb2_get_drv_priv() - return driver private data associated with the queue. + * @q: pointer to &struct vb2_queue with videobuf2 queue. */ static inline void *vb2_get_drv_priv(struct vb2_queue *q) { @@ -961,10 +990,11 @@ static inline void *vb2_get_drv_priv(struct vb2_queue *q) } /** - * vb2_set_plane_payload() - set bytesused for the plane plane_no - * @vb: buffer for which plane payload should be set - * @plane_no: plane number for which payload should be set - * @size: payload in bytes + * vb2_set_plane_payload() - set bytesused for the plane @plane_no. + * @vb: pointer to &struct vb2_buffer to which the plane in + * question belongs to. + * @plane_no: plane number for which payload should be set. + * @size: payload in bytes. */ static inline void vb2_set_plane_payload(struct vb2_buffer *vb, unsigned int plane_no, unsigned long size) @@ -975,8 +1005,9 @@ static inline void vb2_set_plane_payload(struct vb2_buffer *vb, /** * vb2_get_plane_payload() - get bytesused for the plane plane_no - * @vb: buffer for which plane payload should be set - * @plane_no: plane number for which payload should be set + * @vb: pointer to &struct vb2_buffer to which the plane in + * question belongs to. + * @plane_no: plane number for which payload should be set. */ static inline unsigned long vb2_get_plane_payload(struct vb2_buffer *vb, unsigned int plane_no) @@ -987,9 +1018,10 @@ static inline unsigned long vb2_get_plane_payload(struct vb2_buffer *vb, } /** - * vb2_plane_size() - return plane size in bytes - * @vb: buffer for which plane size should be returned - * @plane_no: plane number for which size should be returned + * vb2_plane_size() - return plane size in bytes. + * @vb: pointer to &struct vb2_buffer to which the plane in + * question belongs to. + * @plane_no: plane number for which size should be returned. */ static inline unsigned long vb2_plane_size(struct vb2_buffer *vb, unsigned int plane_no) @@ -1000,8 +1032,8 @@ vb2_plane_size(struct vb2_buffer *vb, unsigned int plane_no) } /** - * vb2_start_streaming_called() - return streaming status of driver - * @q: videobuf queue + * vb2_start_streaming_called() - return streaming status of driver. + * @q: pointer to &struct vb2_queue with videobuf2 queue. */ static inline bool vb2_start_streaming_called(struct vb2_queue *q) { @@ -1009,8 +1041,8 @@ static inline bool vb2_start_streaming_called(struct vb2_queue *q) } /** - * vb2_clear_last_buffer_dequeued() - clear last buffer dequeued flag of queue - * @q: videobuf queue + * vb2_clear_last_buffer_dequeued() - clear last buffer dequeued flag of queue. + * @q: pointer to &struct vb2_queue with videobuf2 queue. */ static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q) { @@ -1024,10 +1056,10 @@ static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q) /** * vb2_buffer_in_use() - return true if the buffer is in use and - * the queue cannot be freed (by the means of REQBUFS(0)) call + * the queue cannot be freed (by the means of VIDIOC_REQBUFS(0)) call. * - * @vb: buffer for which plane size should be returned - * @q: videobuf queue + * @vb: buffer for which plane size should be returned. + * @q: pointer to &struct vb2_queue with videobuf2 queue. */ bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb); @@ -1035,11 +1067,11 @@ bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb); * vb2_verify_memory_type() - Check whether the memory type and buffer type * passed to a buffer operation are compatible with the queue. * - * @q: videobuf queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. * @memory: memory model, as defined by enum &vb2_memory. * @type: private buffer type whose content is defined by the vb2-core * caller. For example, for V4L2, it should match - * the types defined on enum &v4l2_buf_type + * the types defined on enum &v4l2_buf_type. */ int vb2_verify_memory_type(struct vb2_queue *q, enum vb2_memory memory, unsigned int type); -- cgit From 8dcde47ff8c97ad29593cd150cbfcbe9866fd6b5 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 7 Oct 2017 05:05:03 -0400 Subject: media: vb2-core: document remaining functions There are several VB2 core functions that aren't documented. Signed-off-by: Mauro Carvalho Chehab --- include/media/videobuf2-core.h | 54 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index e145f1475ffe..ce795cd0a7cc 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -786,7 +786,28 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb); int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb, bool nonblocking); +/** + * vb2_core_streamon() - Implements VB2 stream ON logic + * + * @q: pointer to &struct vb2_queue with videobuf2 queue + * @type: type of the queue to be started. + * For V4L2, this is defined by &enum v4l2_buf_type type. + * + * Should be called from &v4l2_ioctl_ops->vidioc_streamon ioctl handler of + * a driver. + */ int vb2_core_streamon(struct vb2_queue *q, unsigned int type); + +/** + * vb2_core_streamoff() - Implements VB2 stream OFF logic + * + * @q: pointer to &struct vb2_queue with videobuf2 queue + * @type: type of the queue to be started. + * For V4L2, this is defined by &enum v4l2_buf_type type. + * + * Should be called from &v4l2_ioctl_ops->vidioc_streamon ioctl handler of + * a driver. + */ int vb2_core_streamoff(struct vb2_queue *q, unsigned int type); /** @@ -874,6 +895,21 @@ void vb2_queue_error(struct vb2_queue *q); int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma); #ifndef CONFIG_MMU +/** + * vb2_get_unmapped_area - map video buffers into application address space. + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @addr: memory address. + * @len: buffer size. + * @pgoff: page offset. + * @flags: memory flags. + * + * This function is used in noMMU platforms to propose address mapping + * for a given buffer. It's intended to be used as a handler for the + * &file_operations->get_unmapped_area operation. + * + * This is called by the mmap() syscall routines will call this + * to get a proposed address for the mapping, when ``!CONFIG_MMU``. + */ unsigned long vb2_get_unmapped_area(struct vb2_queue *q, unsigned long addr, unsigned long len, @@ -882,7 +918,7 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q, #endif /** - * vb2_core_poll() - implements poll userspace operation. + * vb2_core_poll() - implements poll syscall() logic. * @q: pointer to &struct vb2_queue with videobuf2 queue. * @file: &struct file argument passed to the poll * file operation handler. @@ -902,8 +938,24 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q, unsigned int vb2_core_poll(struct vb2_queue *q, struct file *file, poll_table *wait); +/** + * vb2_read() - implements read() syscall logic. + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @data: pointed to target userspace buffer + * @count: number of bytes to read + * @ppos: file handle position tracking pointer + * @nonblock: mode selector (1 means blocking calls, 0 means nonblocking) + */ size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count, loff_t *ppos, int nonblock); +/** + * vb2_read() - implements write() syscall logic. + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @data: pointed to target userspace buffer + * @count: number of bytes to write + * @ppos: file handle position tracking pointer + * @nonblock: mode selector (1 means blocking calls, 0 means nonblocking) + */ size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count, loff_t *ppos, int nonblock); -- cgit From 9fbe71b4d8020221268e5c5b6fe02665b046d199 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 9 Oct 2017 05:36:52 -0400 Subject: media: vb2: add cross references at memops and v4l2 kernel-doc markups Add cross-references where needed and add periods at the end of each kernel-doc paragraph, in order to make it coherent with other VB2 descriptions. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/videobuf2-memops.h | 8 +-- include/media/videobuf2-v4l2.h | 112 +++++++++++++++++++++------------------ 2 files changed, 63 insertions(+), 57 deletions(-) (limited to 'include/media') diff --git a/include/media/videobuf2-memops.h b/include/media/videobuf2-memops.h index a6ed091b79ce..4b5b84f93538 100644 --- a/include/media/videobuf2-memops.h +++ b/include/media/videobuf2-memops.h @@ -19,11 +19,11 @@ #include /** - * struct vb2_vmarea_handler - common vma refcount tracking handler + * struct vb2_vmarea_handler - common vma refcount tracking handler. * - * @refcount: pointer to refcount entry in the buffer - * @put: callback to function that decreases buffer refcount - * @arg: argument for @put callback + * @refcount: pointer to &refcount_t entry in the buffer. + * @put: callback to function that decreases buffer refcount. + * @arg: argument for @put callback. */ struct vb2_vmarea_handler { refcount_t *refcount; diff --git a/include/media/videobuf2-v4l2.h b/include/media/videobuf2-v4l2.h index 036127c54bbf..126cf559d4ce 100644 --- a/include/media/videobuf2-v4l2.h +++ b/include/media/videobuf2-v4l2.h @@ -24,16 +24,17 @@ #endif /** - * struct vb2_v4l2_buffer - video buffer information for v4l2 + * struct vb2_v4l2_buffer - video buffer information for v4l2. * - * @vb2_buf: video buffer 2 - * @flags: buffer informational flags - * @field: enum v4l2_field; field order of the image in the buffer - * @timecode: frame timecode - * @sequence: sequence count of this frame + * @vb2_buf: embedded struct &vb2_buffer. + * @flags: buffer informational flags. + * @field: field order of the image in the buffer, as defined by + * &enum v4l2_field. + * @timecode: frame timecode. + * @sequence: sequence count of this frame. * * Should contain enough information to be able to cover all the fields - * of struct v4l2_buffer at videodev2.h + * of &struct v4l2_buffer at ``videodev2.h``. */ struct vb2_v4l2_buffer { struct vb2_buffer vb2_buf; @@ -56,9 +57,9 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b); * vb2_reqbufs() - Wrapper for vb2_core_reqbufs() that also verifies * the memory and type values. * - * @q: videobuf2 queue - * @req: struct passed from userspace to vidioc_reqbufs handler - * in driver + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @req: &struct v4l2_requestbuffers passed from userspace to + * &v4l2_ioctl_ops->vidioc_reqbufs handler in driver. */ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req); @@ -66,94 +67,99 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req); * vb2_create_bufs() - Wrapper for vb2_core_create_bufs() that also verifies * the memory and type values. * - * @q: videobuf2 queue - * @create: creation parameters, passed from userspace to vidioc_create_bufs - * handler in driver + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @create: creation parameters, passed from userspace to + * &v4l2_ioctl_ops->vidioc_create_bufs handler in driver */ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create); /** * vb2_prepare_buf() - Pass ownership of a buffer from userspace to the kernel * - * @q: videobuf2 queue - * @b: buffer structure passed from userspace to vidioc_prepare_buf - * handler in driver + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @b: buffer structure passed from userspace to + * &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver + * + * Should be called from &v4l2_ioctl_ops->vidioc_prepare_buf ioctl handler + * of a driver. * - * Should be called from vidioc_prepare_buf ioctl handler of a driver. * This function: * * #) verifies the passed buffer, - * #) calls buf_prepare callback in the driver (if provided), in which - * driver-specific buffer initialization can be performed. + * #) calls &vb2_ops->buf_prepare callback in the driver (if provided), + * in which driver-specific buffer initialization can be performed. * * The return values from this function are intended to be directly returned - * from vidioc_prepare_buf handler in driver. + * from &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver. */ int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b); /** * vb2_qbuf() - Queue a buffer from userspace - * @q: videobuf2 queue - * @b: buffer structure passed from userspace to VIDIOC_QBUF() handler - * in driver + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @b: buffer structure passed from userspace to + * &v4l2_ioctl_ops->vidioc_qbuf handler in driver * - * Should be called from VIDIOC_QBUF() ioctl handler of a driver. + * Should be called from &v4l2_ioctl_ops->vidioc_qbuf handler of a driver. * * This function: * - * #) verifies the passed buffer, - * #) if necessary, calls buf_prepare callback in the driver (if provided), in - * which driver-specific buffer initialization can be performed, - * #) if streaming is on, queues the buffer in driver by the means of buf_queue - * callback for processing. + * #) verifies the passed buffer; + * #) if necessary, calls &vb2_ops->buf_prepare callback in the driver + * (if provided), in which driver-specific buffer initialization can + * be performed; + * #) if streaming is on, queues the buffer in driver by the means of + * &vb2_ops->buf_queue callback for processing. * * The return values from this function are intended to be directly returned - * from VIDIOC_QBUF() handler in driver. + * from &v4l2_ioctl_ops->vidioc_qbuf handler in driver. */ int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b); /** * vb2_expbuf() - Export a buffer as a file descriptor - * @q: videobuf2 queue - * @eb: export buffer structure passed from userspace to VIDIOC_EXPBUF() - * handler in driver + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @eb: export buffer structure passed from userspace to + * &v4l2_ioctl_ops->vidioc_expbuf handler in driver * * The return values from this function are intended to be directly returned - * from VIDIOC_EXPBUF() handler in driver. + * from &v4l2_ioctl_ops->vidioc_expbuf handler in driver. */ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb); /** * vb2_dqbuf() - Dequeue a buffer to the userspace - * @q: videobuf2 queue - * @b: buffer structure passed from userspace to VIDIOC_DQBUF() handler - * in driver + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @b: buffer structure passed from userspace to + * &v4l2_ioctl_ops->vidioc_dqbuf handler in driver * @nonblocking: if true, this call will not sleep waiting for a buffer if no * buffers ready for dequeuing are present. Normally the driver - * would be passing (file->f_flags & O_NONBLOCK) here + * would be passing (&file->f_flags & %O_NONBLOCK) here * - * Should be called from VIDIOC_DQBUF() ioctl handler of a driver. + * Should be called from &v4l2_ioctl_ops->vidioc_dqbuf ioctl handler + * of a driver. * * This function: * - * #) verifies the passed buffer, - * #) calls buf_finish callback in the driver (if provided), in which + * #) verifies the passed buffer; + * #) calls &vb2_ops->buf_finish callback in the driver (if provided), in which * driver can perform any additional operations that may be required before - * returning the buffer to userspace, such as cache sync, + * returning the buffer to userspace, such as cache sync; * #) the buffer struct members are filled with relevant information for * the userspace. * * The return values from this function are intended to be directly returned - * from VIDIOC_DQBUF() handler in driver. + * from &v4l2_ioctl_ops->vidioc_dqbuf handler in driver. */ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking); /** * vb2_streamon - start streaming - * @q: videobuf2 queue - * @type: type argument passed from userspace to vidioc_streamon handler + * @q: pointer to &struct vb2_queue with videobuf2 queue. + * @type: type argument passed from userspace to vidioc_streamon handler, + * as defined by &enum v4l2_buf_type. * - * Should be called from vidioc_streamon handler of a driver. + * Should be called from &v4l2_ioctl_ops->vidioc_streamon handler of a driver. * * This function: * @@ -161,13 +167,13 @@ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking); * 2) passes any previously queued buffers to the driver and starts streaming * * The return values from this function are intended to be directly returned - * from vidioc_streamon handler in the driver. + * from &v4l2_ioctl_ops->vidioc_streamon handler in the driver. */ int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type); /** * vb2_streamoff - stop streaming - * @q: videobuf2 queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. * @type: type argument passed from userspace to vidioc_streamoff handler * * Should be called from vidioc_streamoff handler of a driver. @@ -186,7 +192,7 @@ int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type); /** * vb2_queue_init() - initialize a videobuf2 queue - * @q: videobuf2 queue; this structure should be allocated in driver + * @q: pointer to &struct vb2_queue with videobuf2 queue. * * The vb2_queue structure should be allocated by the driver. The driver is * responsible of clearing it's content and setting initial values for some @@ -199,7 +205,7 @@ int __must_check vb2_queue_init(struct vb2_queue *q); /** * vb2_queue_release() - stop streaming, release the queue and free memory - * @q: videobuf2 queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. * * This function stops streaming and performs necessary clean ups, including * freeing video buffer memory. The driver is responsible for freeing @@ -209,7 +215,7 @@ void vb2_queue_release(struct vb2_queue *q); /** * vb2_poll() - implements poll userspace operation - * @q: videobuf2 queue + * @q: pointer to &struct vb2_queue with videobuf2 queue. * @file: file argument passed to the poll file operation handler * @wait: wait argument passed to the poll file operation handler * @@ -271,7 +277,7 @@ unsigned long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr, /** * vb2_ops_wait_prepare - helper function to lock a struct &vb2_queue * - * @vq: pointer to struct vb2_queue + * @vq: pointer to &struct vb2_queue * * ..note:: only use if vq->lock is non-NULL. */ @@ -280,7 +286,7 @@ void vb2_ops_wait_prepare(struct vb2_queue *vq); /** * vb2_ops_wait_finish - helper function to unlock a struct &vb2_queue * - * @vq: pointer to struct vb2_queue + * @vq: pointer to &struct vb2_queue * * ..note:: only use if vq->lock is non-NULL. */ -- cgit From 1beb623bdab53fb148b0ae4161b816e40ed16ca1 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 9 Oct 2017 06:02:25 -0400 Subject: media: v4l2-tpg*.h: move headers to include/media/tpg and merge them The v4l2-tpg*.h headers are meant to be used only internally by vivid and vimc. There's no sense keeping them together with the V4L2 kAPI headers. Also, one header includes the other as they're meant to be used together. So, merge them. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/tpg/v4l2-tpg.h | 662 ++++++++++++++++++++++++++++++++++++++++ include/media/v4l2-tpg-colors.h | 68 ----- include/media/v4l2-tpg.h | 619 ------------------------------------- 3 files changed, 662 insertions(+), 687 deletions(-) create mode 100644 include/media/tpg/v4l2-tpg.h delete mode 100644 include/media/v4l2-tpg-colors.h delete mode 100644 include/media/v4l2-tpg.h (limited to 'include/media') diff --git a/include/media/tpg/v4l2-tpg.h b/include/media/tpg/v4l2-tpg.h new file mode 100644 index 000000000000..028d81182011 --- /dev/null +++ b/include/media/tpg/v4l2-tpg.h @@ -0,0 +1,662 @@ +/* + * v4l2-tpg.h - Test Pattern Generator + * + * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * + * This program is free software; you may redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _V4L2_TPG_H_ +#define _V4L2_TPG_H_ + +#include +#include +#include +#include +#include +#include + +struct color { + unsigned char r, g, b; +}; + +struct color16 { + int r, g, b; +}; + +enum tpg_color { + TPG_COLOR_CSC_WHITE, + TPG_COLOR_CSC_YELLOW, + TPG_COLOR_CSC_CYAN, + TPG_COLOR_CSC_GREEN, + TPG_COLOR_CSC_MAGENTA, + TPG_COLOR_CSC_RED, + TPG_COLOR_CSC_BLUE, + TPG_COLOR_CSC_BLACK, + TPG_COLOR_75_YELLOW, + TPG_COLOR_75_CYAN, + TPG_COLOR_75_GREEN, + TPG_COLOR_75_MAGENTA, + TPG_COLOR_75_RED, + TPG_COLOR_75_BLUE, + TPG_COLOR_100_WHITE, + TPG_COLOR_100_YELLOW, + TPG_COLOR_100_CYAN, + TPG_COLOR_100_GREEN, + TPG_COLOR_100_MAGENTA, + TPG_COLOR_100_RED, + TPG_COLOR_100_BLUE, + TPG_COLOR_100_BLACK, + TPG_COLOR_TEXTFG, + TPG_COLOR_TEXTBG, + TPG_COLOR_RANDOM, + TPG_COLOR_RAMP, + TPG_COLOR_MAX = TPG_COLOR_RAMP + 256 +}; + +extern const struct color tpg_colors[TPG_COLOR_MAX]; +extern const unsigned short tpg_rec709_to_linear[255 * 16 + 1]; +extern const unsigned short tpg_linear_to_rec709[255 * 16 + 1]; +extern const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1] + [V4L2_XFER_FUNC_SMPTE2084 + 1] + [TPG_COLOR_CSC_BLACK + 1]; +enum tpg_pattern { + TPG_PAT_75_COLORBAR, + TPG_PAT_100_COLORBAR, + TPG_PAT_CSC_COLORBAR, + TPG_PAT_100_HCOLORBAR, + TPG_PAT_100_COLORSQUARES, + TPG_PAT_BLACK, + TPG_PAT_WHITE, + TPG_PAT_RED, + TPG_PAT_GREEN, + TPG_PAT_BLUE, + TPG_PAT_CHECKERS_16X16, + TPG_PAT_CHECKERS_2X2, + TPG_PAT_CHECKERS_1X1, + TPG_PAT_COLOR_CHECKERS_2X2, + TPG_PAT_COLOR_CHECKERS_1X1, + TPG_PAT_ALTERNATING_HLINES, + TPG_PAT_ALTERNATING_VLINES, + TPG_PAT_CROSS_1_PIXEL, + TPG_PAT_CROSS_2_PIXELS, + TPG_PAT_CROSS_10_PIXELS, + TPG_PAT_GRAY_RAMP, + + /* Must be the last pattern */ + TPG_PAT_NOISE, +}; + +extern const char * const tpg_pattern_strings[]; + +enum tpg_quality { + TPG_QUAL_COLOR, + TPG_QUAL_GRAY, + TPG_QUAL_NOISE +}; + +enum tpg_video_aspect { + TPG_VIDEO_ASPECT_IMAGE, + TPG_VIDEO_ASPECT_4X3, + TPG_VIDEO_ASPECT_14X9_CENTRE, + TPG_VIDEO_ASPECT_16X9_CENTRE, + TPG_VIDEO_ASPECT_16X9_ANAMORPHIC, +}; + +enum tpg_pixel_aspect { + TPG_PIXEL_ASPECT_SQUARE, + TPG_PIXEL_ASPECT_NTSC, + TPG_PIXEL_ASPECT_PAL, +}; + +enum tpg_move_mode { + TPG_MOVE_NEG_FAST, + TPG_MOVE_NEG, + TPG_MOVE_NEG_SLOW, + TPG_MOVE_NONE, + TPG_MOVE_POS_SLOW, + TPG_MOVE_POS, + TPG_MOVE_POS_FAST, +}; + +enum tgp_color_enc { + TGP_COLOR_ENC_RGB, + TGP_COLOR_ENC_YCBCR, + TGP_COLOR_ENC_HSV, + TGP_COLOR_ENC_LUMA, +}; + +extern const char * const tpg_aspect_strings[]; + +#define TPG_MAX_PLANES 3 +#define TPG_MAX_PAT_LINES 8 + +struct tpg_data { + /* Source frame size */ + unsigned src_width, src_height; + /* Buffer height */ + unsigned buf_height; + /* Scaled output frame size */ + unsigned scaled_width; + u32 field; + bool field_alternate; + /* crop coordinates are frame-based */ + struct v4l2_rect crop; + /* compose coordinates are format-based */ + struct v4l2_rect compose; + /* border and square coordinates are frame-based */ + struct v4l2_rect border; + struct v4l2_rect square; + + /* Color-related fields */ + enum tpg_quality qual; + unsigned qual_offset; + u8 alpha_component; + bool alpha_red_only; + u8 brightness; + u8 contrast; + u8 saturation; + s16 hue; + u32 fourcc; + enum tgp_color_enc color_enc; + u32 colorspace; + u32 xfer_func; + u32 ycbcr_enc; + u32 hsv_enc; + /* + * Stores the actual transfer function, i.e. will never be + * V4L2_XFER_FUNC_DEFAULT. + */ + u32 real_xfer_func; + /* + * Stores the actual Y'CbCr encoding, i.e. will never be + * V4L2_YCBCR_ENC_DEFAULT. + */ + u32 real_hsv_enc; + u32 real_ycbcr_enc; + u32 quantization; + /* + * Stores the actual quantization, i.e. will never be + * V4L2_QUANTIZATION_DEFAULT. + */ + u32 real_quantization; + enum tpg_video_aspect vid_aspect; + enum tpg_pixel_aspect pix_aspect; + unsigned rgb_range; + unsigned real_rgb_range; + unsigned buffers; + unsigned planes; + bool interleaved; + u8 vdownsampling[TPG_MAX_PLANES]; + u8 hdownsampling[TPG_MAX_PLANES]; + /* + * horizontal positions must be ANDed with this value to enforce + * correct boundaries for packed YUYV values. + */ + unsigned hmask[TPG_MAX_PLANES]; + /* Used to store the colors in native format, either RGB or YUV */ + u8 colors[TPG_COLOR_MAX][3]; + u8 textfg[TPG_MAX_PLANES][8], textbg[TPG_MAX_PLANES][8]; + /* size in bytes for two pixels in each plane */ + unsigned twopixelsize[TPG_MAX_PLANES]; + unsigned bytesperline[TPG_MAX_PLANES]; + + /* Configuration */ + enum tpg_pattern pattern; + bool hflip; + bool vflip; + unsigned perc_fill; + bool perc_fill_blank; + bool show_border; + bool show_square; + bool insert_sav; + bool insert_eav; + + /* Test pattern movement */ + enum tpg_move_mode mv_hor_mode; + int mv_hor_count; + int mv_hor_step; + enum tpg_move_mode mv_vert_mode; + int mv_vert_count; + int mv_vert_step; + + bool recalc_colors; + bool recalc_lines; + bool recalc_square_border; + + /* Used to store TPG_MAX_PAT_LINES lines, each with up to two planes */ + unsigned max_line_width; + u8 *lines[TPG_MAX_PAT_LINES][TPG_MAX_PLANES]; + u8 *downsampled_lines[TPG_MAX_PAT_LINES][TPG_MAX_PLANES]; + u8 *random_line[TPG_MAX_PLANES]; + u8 *contrast_line[TPG_MAX_PLANES]; + u8 *black_line[TPG_MAX_PLANES]; +}; + +void tpg_init(struct tpg_data *tpg, unsigned w, unsigned h); +int tpg_alloc(struct tpg_data *tpg, unsigned max_w); +void tpg_free(struct tpg_data *tpg); +void tpg_reset_source(struct tpg_data *tpg, unsigned width, unsigned height, + u32 field); +void tpg_log_status(struct tpg_data *tpg); + +void tpg_set_font(const u8 *f); +void tpg_gen_text(const struct tpg_data *tpg, + u8 *basep[TPG_MAX_PLANES][2], int y, int x, char *text); +void tpg_calc_text_basep(struct tpg_data *tpg, + u8 *basep[TPG_MAX_PLANES][2], unsigned p, u8 *vbuf); +unsigned tpg_g_interleaved_plane(const struct tpg_data *tpg, unsigned buf_line); +void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, + unsigned p, u8 *vbuf); +void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, + unsigned p, u8 *vbuf); +bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc); +void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop, + const struct v4l2_rect *compose); + +static inline void tpg_s_pattern(struct tpg_data *tpg, enum tpg_pattern pattern) +{ + if (tpg->pattern == pattern) + return; + tpg->pattern = pattern; + tpg->recalc_colors = true; +} + +static inline void tpg_s_quality(struct tpg_data *tpg, + enum tpg_quality qual, unsigned qual_offset) +{ + if (tpg->qual == qual && tpg->qual_offset == qual_offset) + return; + tpg->qual = qual; + tpg->qual_offset = qual_offset; + tpg->recalc_colors = true; +} + +static inline enum tpg_quality tpg_g_quality(const struct tpg_data *tpg) +{ + return tpg->qual; +} + +static inline void tpg_s_alpha_component(struct tpg_data *tpg, + u8 alpha_component) +{ + if (tpg->alpha_component == alpha_component) + return; + tpg->alpha_component = alpha_component; + tpg->recalc_colors = true; +} + +static inline void tpg_s_alpha_mode(struct tpg_data *tpg, + bool red_only) +{ + if (tpg->alpha_red_only == red_only) + return; + tpg->alpha_red_only = red_only; + tpg->recalc_colors = true; +} + +static inline void tpg_s_brightness(struct tpg_data *tpg, + u8 brightness) +{ + if (tpg->brightness == brightness) + return; + tpg->brightness = brightness; + tpg->recalc_colors = true; +} + +static inline void tpg_s_contrast(struct tpg_data *tpg, + u8 contrast) +{ + if (tpg->contrast == contrast) + return; + tpg->contrast = contrast; + tpg->recalc_colors = true; +} + +static inline void tpg_s_saturation(struct tpg_data *tpg, + u8 saturation) +{ + if (tpg->saturation == saturation) + return; + tpg->saturation = saturation; + tpg->recalc_colors = true; +} + +static inline void tpg_s_hue(struct tpg_data *tpg, + s16 hue) +{ + if (tpg->hue == hue) + return; + tpg->hue = hue; + tpg->recalc_colors = true; +} + +static inline void tpg_s_rgb_range(struct tpg_data *tpg, + unsigned rgb_range) +{ + if (tpg->rgb_range == rgb_range) + return; + tpg->rgb_range = rgb_range; + tpg->recalc_colors = true; +} + +static inline void tpg_s_real_rgb_range(struct tpg_data *tpg, + unsigned rgb_range) +{ + if (tpg->real_rgb_range == rgb_range) + return; + tpg->real_rgb_range = rgb_range; + tpg->recalc_colors = true; +} + +static inline void tpg_s_colorspace(struct tpg_data *tpg, u32 colorspace) +{ + if (tpg->colorspace == colorspace) + return; + tpg->colorspace = colorspace; + tpg->recalc_colors = true; +} + +static inline u32 tpg_g_colorspace(const struct tpg_data *tpg) +{ + return tpg->colorspace; +} + +static inline void tpg_s_ycbcr_enc(struct tpg_data *tpg, u32 ycbcr_enc) +{ + if (tpg->ycbcr_enc == ycbcr_enc) + return; + tpg->ycbcr_enc = ycbcr_enc; + tpg->recalc_colors = true; +} + +static inline u32 tpg_g_ycbcr_enc(const struct tpg_data *tpg) +{ + return tpg->ycbcr_enc; +} + +static inline void tpg_s_hsv_enc(struct tpg_data *tpg, u32 hsv_enc) +{ + if (tpg->hsv_enc == hsv_enc) + return; + tpg->hsv_enc = hsv_enc; + tpg->recalc_colors = true; +} + +static inline u32 tpg_g_hsv_enc(const struct tpg_data *tpg) +{ + return tpg->hsv_enc; +} + +static inline void tpg_s_xfer_func(struct tpg_data *tpg, u32 xfer_func) +{ + if (tpg->xfer_func == xfer_func) + return; + tpg->xfer_func = xfer_func; + tpg->recalc_colors = true; +} + +static inline u32 tpg_g_xfer_func(const struct tpg_data *tpg) +{ + return tpg->xfer_func; +} + +static inline void tpg_s_quantization(struct tpg_data *tpg, u32 quantization) +{ + if (tpg->quantization == quantization) + return; + tpg->quantization = quantization; + tpg->recalc_colors = true; +} + +static inline u32 tpg_g_quantization(const struct tpg_data *tpg) +{ + return tpg->quantization; +} + +static inline unsigned tpg_g_buffers(const struct tpg_data *tpg) +{ + return tpg->buffers; +} + +static inline unsigned tpg_g_planes(const struct tpg_data *tpg) +{ + return tpg->interleaved ? 1 : tpg->planes; +} + +static inline bool tpg_g_interleaved(const struct tpg_data *tpg) +{ + return tpg->interleaved; +} + +static inline unsigned tpg_g_twopixelsize(const struct tpg_data *tpg, unsigned plane) +{ + return tpg->twopixelsize[plane]; +} + +static inline unsigned tpg_hdiv(const struct tpg_data *tpg, + unsigned plane, unsigned x) +{ + return ((x / tpg->hdownsampling[plane]) & tpg->hmask[plane]) * + tpg->twopixelsize[plane] / 2; +} + +static inline unsigned tpg_hscale(const struct tpg_data *tpg, unsigned x) +{ + return (x * tpg->scaled_width) / tpg->src_width; +} + +static inline unsigned tpg_hscale_div(const struct tpg_data *tpg, + unsigned plane, unsigned x) +{ + return tpg_hdiv(tpg, plane, tpg_hscale(tpg, x)); +} + +static inline unsigned tpg_g_bytesperline(const struct tpg_data *tpg, unsigned plane) +{ + return tpg->bytesperline[plane]; +} + +static inline void tpg_s_bytesperline(struct tpg_data *tpg, unsigned plane, unsigned bpl) +{ + unsigned p; + + if (tpg->buffers > 1) { + tpg->bytesperline[plane] = bpl; + return; + } + + for (p = 0; p < tpg_g_planes(tpg); p++) { + unsigned plane_w = bpl * tpg->twopixelsize[p] / tpg->twopixelsize[0]; + + tpg->bytesperline[p] = plane_w / tpg->hdownsampling[p]; + } + if (tpg_g_interleaved(tpg)) + tpg->bytesperline[1] = tpg->bytesperline[0]; +} + + +static inline unsigned tpg_g_line_width(const struct tpg_data *tpg, unsigned plane) +{ + unsigned w = 0; + unsigned p; + + if (tpg->buffers > 1) + return tpg_g_bytesperline(tpg, plane); + for (p = 0; p < tpg_g_planes(tpg); p++) { + unsigned plane_w = tpg_g_bytesperline(tpg, p); + + w += plane_w / tpg->vdownsampling[p]; + } + return w; +} + +static inline unsigned tpg_calc_line_width(const struct tpg_data *tpg, + unsigned plane, unsigned bpl) +{ + unsigned w = 0; + unsigned p; + + if (tpg->buffers > 1) + return bpl; + for (p = 0; p < tpg_g_planes(tpg); p++) { + unsigned plane_w = bpl * tpg->twopixelsize[p] / tpg->twopixelsize[0]; + + plane_w /= tpg->hdownsampling[p]; + w += plane_w / tpg->vdownsampling[p]; + } + return w; +} + +static inline unsigned tpg_calc_plane_size(const struct tpg_data *tpg, unsigned plane) +{ + if (plane >= tpg_g_planes(tpg)) + return 0; + + return tpg_g_bytesperline(tpg, plane) * tpg->buf_height / + tpg->vdownsampling[plane]; +} + +static inline void tpg_s_buf_height(struct tpg_data *tpg, unsigned h) +{ + tpg->buf_height = h; +} + +static inline void tpg_s_field(struct tpg_data *tpg, unsigned field, bool alternate) +{ + tpg->field = field; + tpg->field_alternate = alternate; +} + +static inline void tpg_s_perc_fill(struct tpg_data *tpg, + unsigned perc_fill) +{ + tpg->perc_fill = perc_fill; +} + +static inline unsigned tpg_g_perc_fill(const struct tpg_data *tpg) +{ + return tpg->perc_fill; +} + +static inline void tpg_s_perc_fill_blank(struct tpg_data *tpg, + bool perc_fill_blank) +{ + tpg->perc_fill_blank = perc_fill_blank; +} + +static inline void tpg_s_video_aspect(struct tpg_data *tpg, + enum tpg_video_aspect vid_aspect) +{ + if (tpg->vid_aspect == vid_aspect) + return; + tpg->vid_aspect = vid_aspect; + tpg->recalc_square_border = true; +} + +static inline enum tpg_video_aspect tpg_g_video_aspect(const struct tpg_data *tpg) +{ + return tpg->vid_aspect; +} + +static inline void tpg_s_pixel_aspect(struct tpg_data *tpg, + enum tpg_pixel_aspect pix_aspect) +{ + if (tpg->pix_aspect == pix_aspect) + return; + tpg->pix_aspect = pix_aspect; + tpg->recalc_square_border = true; +} + +static inline void tpg_s_show_border(struct tpg_data *tpg, + bool show_border) +{ + tpg->show_border = show_border; +} + +static inline void tpg_s_show_square(struct tpg_data *tpg, + bool show_square) +{ + tpg->show_square = show_square; +} + +static inline void tpg_s_insert_sav(struct tpg_data *tpg, bool insert_sav) +{ + tpg->insert_sav = insert_sav; +} + +static inline void tpg_s_insert_eav(struct tpg_data *tpg, bool insert_eav) +{ + tpg->insert_eav = insert_eav; +} + +void tpg_update_mv_step(struct tpg_data *tpg); + +static inline void tpg_s_mv_hor_mode(struct tpg_data *tpg, + enum tpg_move_mode mv_hor_mode) +{ + tpg->mv_hor_mode = mv_hor_mode; + tpg_update_mv_step(tpg); +} + +static inline void tpg_s_mv_vert_mode(struct tpg_data *tpg, + enum tpg_move_mode mv_vert_mode) +{ + tpg->mv_vert_mode = mv_vert_mode; + tpg_update_mv_step(tpg); +} + +static inline void tpg_init_mv_count(struct tpg_data *tpg) +{ + tpg->mv_hor_count = tpg->mv_vert_count = 0; +} + +static inline void tpg_update_mv_count(struct tpg_data *tpg, bool frame_is_field) +{ + tpg->mv_hor_count += tpg->mv_hor_step * (frame_is_field ? 1 : 2); + tpg->mv_vert_count += tpg->mv_vert_step * (frame_is_field ? 1 : 2); +} + +static inline void tpg_s_hflip(struct tpg_data *tpg, bool hflip) +{ + if (tpg->hflip == hflip) + return; + tpg->hflip = hflip; + tpg_update_mv_step(tpg); + tpg->recalc_lines = true; +} + +static inline bool tpg_g_hflip(const struct tpg_data *tpg) +{ + return tpg->hflip; +} + +static inline void tpg_s_vflip(struct tpg_data *tpg, bool vflip) +{ + tpg->vflip = vflip; +} + +static inline bool tpg_g_vflip(const struct tpg_data *tpg) +{ + return tpg->vflip; +} + +static inline bool tpg_pattern_is_static(const struct tpg_data *tpg) +{ + return tpg->pattern != TPG_PAT_NOISE && + tpg->mv_hor_mode == TPG_MOVE_NONE && + tpg->mv_vert_mode == TPG_MOVE_NONE; +} + +#endif diff --git a/include/media/v4l2-tpg-colors.h b/include/media/v4l2-tpg-colors.h deleted file mode 100644 index 2a88d1fae0cd..000000000000 --- a/include/media/v4l2-tpg-colors.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * v4l2-tpg-colors.h - Color definitions for the test pattern generator - * - * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved. - * - * This program is free software; you may redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _V4L2_TPG_COLORS_H_ -#define _V4L2_TPG_COLORS_H_ - -struct color { - unsigned char r, g, b; -}; - -struct color16 { - int r, g, b; -}; - -enum tpg_color { - TPG_COLOR_CSC_WHITE, - TPG_COLOR_CSC_YELLOW, - TPG_COLOR_CSC_CYAN, - TPG_COLOR_CSC_GREEN, - TPG_COLOR_CSC_MAGENTA, - TPG_COLOR_CSC_RED, - TPG_COLOR_CSC_BLUE, - TPG_COLOR_CSC_BLACK, - TPG_COLOR_75_YELLOW, - TPG_COLOR_75_CYAN, - TPG_COLOR_75_GREEN, - TPG_COLOR_75_MAGENTA, - TPG_COLOR_75_RED, - TPG_COLOR_75_BLUE, - TPG_COLOR_100_WHITE, - TPG_COLOR_100_YELLOW, - TPG_COLOR_100_CYAN, - TPG_COLOR_100_GREEN, - TPG_COLOR_100_MAGENTA, - TPG_COLOR_100_RED, - TPG_COLOR_100_BLUE, - TPG_COLOR_100_BLACK, - TPG_COLOR_TEXTFG, - TPG_COLOR_TEXTBG, - TPG_COLOR_RANDOM, - TPG_COLOR_RAMP, - TPG_COLOR_MAX = TPG_COLOR_RAMP + 256 -}; - -extern const struct color tpg_colors[TPG_COLOR_MAX]; -extern const unsigned short tpg_rec709_to_linear[255 * 16 + 1]; -extern const unsigned short tpg_linear_to_rec709[255 * 16 + 1]; -extern const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1] - [V4L2_XFER_FUNC_SMPTE2084 + 1] - [TPG_COLOR_CSC_BLACK + 1]; - -#endif diff --git a/include/media/v4l2-tpg.h b/include/media/v4l2-tpg.h deleted file mode 100644 index 13e49d85cae3..000000000000 --- a/include/media/v4l2-tpg.h +++ /dev/null @@ -1,619 +0,0 @@ -/* - * v4l2-tpg.h - Test Pattern Generator - * - * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved. - * - * This program is free software; you may redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef _V4L2_TPG_H_ -#define _V4L2_TPG_H_ - -#include -#include -#include -#include -#include -#include -#include - -enum tpg_pattern { - TPG_PAT_75_COLORBAR, - TPG_PAT_100_COLORBAR, - TPG_PAT_CSC_COLORBAR, - TPG_PAT_100_HCOLORBAR, - TPG_PAT_100_COLORSQUARES, - TPG_PAT_BLACK, - TPG_PAT_WHITE, - TPG_PAT_RED, - TPG_PAT_GREEN, - TPG_PAT_BLUE, - TPG_PAT_CHECKERS_16X16, - TPG_PAT_CHECKERS_2X2, - TPG_PAT_CHECKERS_1X1, - TPG_PAT_COLOR_CHECKERS_2X2, - TPG_PAT_COLOR_CHECKERS_1X1, - TPG_PAT_ALTERNATING_HLINES, - TPG_PAT_ALTERNATING_VLINES, - TPG_PAT_CROSS_1_PIXEL, - TPG_PAT_CROSS_2_PIXELS, - TPG_PAT_CROSS_10_PIXELS, - TPG_PAT_GRAY_RAMP, - - /* Must be the last pattern */ - TPG_PAT_NOISE, -}; - -extern const char * const tpg_pattern_strings[]; - -enum tpg_quality { - TPG_QUAL_COLOR, - TPG_QUAL_GRAY, - TPG_QUAL_NOISE -}; - -enum tpg_video_aspect { - TPG_VIDEO_ASPECT_IMAGE, - TPG_VIDEO_ASPECT_4X3, - TPG_VIDEO_ASPECT_14X9_CENTRE, - TPG_VIDEO_ASPECT_16X9_CENTRE, - TPG_VIDEO_ASPECT_16X9_ANAMORPHIC, -}; - -enum tpg_pixel_aspect { - TPG_PIXEL_ASPECT_SQUARE, - TPG_PIXEL_ASPECT_NTSC, - TPG_PIXEL_ASPECT_PAL, -}; - -enum tpg_move_mode { - TPG_MOVE_NEG_FAST, - TPG_MOVE_NEG, - TPG_MOVE_NEG_SLOW, - TPG_MOVE_NONE, - TPG_MOVE_POS_SLOW, - TPG_MOVE_POS, - TPG_MOVE_POS_FAST, -}; - -enum tgp_color_enc { - TGP_COLOR_ENC_RGB, - TGP_COLOR_ENC_YCBCR, - TGP_COLOR_ENC_HSV, - TGP_COLOR_ENC_LUMA, -}; - -extern const char * const tpg_aspect_strings[]; - -#define TPG_MAX_PLANES 3 -#define TPG_MAX_PAT_LINES 8 - -struct tpg_data { - /* Source frame size */ - unsigned src_width, src_height; - /* Buffer height */ - unsigned buf_height; - /* Scaled output frame size */ - unsigned scaled_width; - u32 field; - bool field_alternate; - /* crop coordinates are frame-based */ - struct v4l2_rect crop; - /* compose coordinates are format-based */ - struct v4l2_rect compose; - /* border and square coordinates are frame-based */ - struct v4l2_rect border; - struct v4l2_rect square; - - /* Color-related fields */ - enum tpg_quality qual; - unsigned qual_offset; - u8 alpha_component; - bool alpha_red_only; - u8 brightness; - u8 contrast; - u8 saturation; - s16 hue; - u32 fourcc; - enum tgp_color_enc color_enc; - u32 colorspace; - u32 xfer_func; - u32 ycbcr_enc; - u32 hsv_enc; - /* - * Stores the actual transfer function, i.e. will never be - * V4L2_XFER_FUNC_DEFAULT. - */ - u32 real_xfer_func; - /* - * Stores the actual Y'CbCr encoding, i.e. will never be - * V4L2_YCBCR_ENC_DEFAULT. - */ - u32 real_hsv_enc; - u32 real_ycbcr_enc; - u32 quantization; - /* - * Stores the actual quantization, i.e. will never be - * V4L2_QUANTIZATION_DEFAULT. - */ - u32 real_quantization; - enum tpg_video_aspect vid_aspect; - enum tpg_pixel_aspect pix_aspect; - unsigned rgb_range; - unsigned real_rgb_range; - unsigned buffers; - unsigned planes; - bool interleaved; - u8 vdownsampling[TPG_MAX_PLANES]; - u8 hdownsampling[TPG_MAX_PLANES]; - /* - * horizontal positions must be ANDed with this value to enforce - * correct boundaries for packed YUYV values. - */ - unsigned hmask[TPG_MAX_PLANES]; - /* Used to store the colors in native format, either RGB or YUV */ - u8 colors[TPG_COLOR_MAX][3]; - u8 textfg[TPG_MAX_PLANES][8], textbg[TPG_MAX_PLANES][8]; - /* size in bytes for two pixels in each plane */ - unsigned twopixelsize[TPG_MAX_PLANES]; - unsigned bytesperline[TPG_MAX_PLANES]; - - /* Configuration */ - enum tpg_pattern pattern; - bool hflip; - bool vflip; - unsigned perc_fill; - bool perc_fill_blank; - bool show_border; - bool show_square; - bool insert_sav; - bool insert_eav; - - /* Test pattern movement */ - enum tpg_move_mode mv_hor_mode; - int mv_hor_count; - int mv_hor_step; - enum tpg_move_mode mv_vert_mode; - int mv_vert_count; - int mv_vert_step; - - bool recalc_colors; - bool recalc_lines; - bool recalc_square_border; - - /* Used to store TPG_MAX_PAT_LINES lines, each with up to two planes */ - unsigned max_line_width; - u8 *lines[TPG_MAX_PAT_LINES][TPG_MAX_PLANES]; - u8 *downsampled_lines[TPG_MAX_PAT_LINES][TPG_MAX_PLANES]; - u8 *random_line[TPG_MAX_PLANES]; - u8 *contrast_line[TPG_MAX_PLANES]; - u8 *black_line[TPG_MAX_PLANES]; -}; - -void tpg_init(struct tpg_data *tpg, unsigned w, unsigned h); -int tpg_alloc(struct tpg_data *tpg, unsigned max_w); -void tpg_free(struct tpg_data *tpg); -void tpg_reset_source(struct tpg_data *tpg, unsigned width, unsigned height, - u32 field); -void tpg_log_status(struct tpg_data *tpg); - -void tpg_set_font(const u8 *f); -void tpg_gen_text(const struct tpg_data *tpg, - u8 *basep[TPG_MAX_PLANES][2], int y, int x, char *text); -void tpg_calc_text_basep(struct tpg_data *tpg, - u8 *basep[TPG_MAX_PLANES][2], unsigned p, u8 *vbuf); -unsigned tpg_g_interleaved_plane(const struct tpg_data *tpg, unsigned buf_line); -void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, - unsigned p, u8 *vbuf); -void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, - unsigned p, u8 *vbuf); -bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc); -void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop, - const struct v4l2_rect *compose); - -static inline void tpg_s_pattern(struct tpg_data *tpg, enum tpg_pattern pattern) -{ - if (tpg->pattern == pattern) - return; - tpg->pattern = pattern; - tpg->recalc_colors = true; -} - -static inline void tpg_s_quality(struct tpg_data *tpg, - enum tpg_quality qual, unsigned qual_offset) -{ - if (tpg->qual == qual && tpg->qual_offset == qual_offset) - return; - tpg->qual = qual; - tpg->qual_offset = qual_offset; - tpg->recalc_colors = true; -} - -static inline enum tpg_quality tpg_g_quality(const struct tpg_data *tpg) -{ - return tpg->qual; -} - -static inline void tpg_s_alpha_component(struct tpg_data *tpg, - u8 alpha_component) -{ - if (tpg->alpha_component == alpha_component) - return; - tpg->alpha_component = alpha_component; - tpg->recalc_colors = true; -} - -static inline void tpg_s_alpha_mode(struct tpg_data *tpg, - bool red_only) -{ - if (tpg->alpha_red_only == red_only) - return; - tpg->alpha_red_only = red_only; - tpg->recalc_colors = true; -} - -static inline void tpg_s_brightness(struct tpg_data *tpg, - u8 brightness) -{ - if (tpg->brightness == brightness) - return; - tpg->brightness = brightness; - tpg->recalc_colors = true; -} - -static inline void tpg_s_contrast(struct tpg_data *tpg, - u8 contrast) -{ - if (tpg->contrast == contrast) - return; - tpg->contrast = contrast; - tpg->recalc_colors = true; -} - -static inline void tpg_s_saturation(struct tpg_data *tpg, - u8 saturation) -{ - if (tpg->saturation == saturation) - return; - tpg->saturation = saturation; - tpg->recalc_colors = true; -} - -static inline void tpg_s_hue(struct tpg_data *tpg, - s16 hue) -{ - if (tpg->hue == hue) - return; - tpg->hue = hue; - tpg->recalc_colors = true; -} - -static inline void tpg_s_rgb_range(struct tpg_data *tpg, - unsigned rgb_range) -{ - if (tpg->rgb_range == rgb_range) - return; - tpg->rgb_range = rgb_range; - tpg->recalc_colors = true; -} - -static inline void tpg_s_real_rgb_range(struct tpg_data *tpg, - unsigned rgb_range) -{ - if (tpg->real_rgb_range == rgb_range) - return; - tpg->real_rgb_range = rgb_range; - tpg->recalc_colors = true; -} - -static inline void tpg_s_colorspace(struct tpg_data *tpg, u32 colorspace) -{ - if (tpg->colorspace == colorspace) - return; - tpg->colorspace = colorspace; - tpg->recalc_colors = true; -} - -static inline u32 tpg_g_colorspace(const struct tpg_data *tpg) -{ - return tpg->colorspace; -} - -static inline void tpg_s_ycbcr_enc(struct tpg_data *tpg, u32 ycbcr_enc) -{ - if (tpg->ycbcr_enc == ycbcr_enc) - return; - tpg->ycbcr_enc = ycbcr_enc; - tpg->recalc_colors = true; -} - -static inline u32 tpg_g_ycbcr_enc(const struct tpg_data *tpg) -{ - return tpg->ycbcr_enc; -} - -static inline void tpg_s_hsv_enc(struct tpg_data *tpg, u32 hsv_enc) -{ - if (tpg->hsv_enc == hsv_enc) - return; - tpg->hsv_enc = hsv_enc; - tpg->recalc_colors = true; -} - -static inline u32 tpg_g_hsv_enc(const struct tpg_data *tpg) -{ - return tpg->hsv_enc; -} - -static inline void tpg_s_xfer_func(struct tpg_data *tpg, u32 xfer_func) -{ - if (tpg->xfer_func == xfer_func) - return; - tpg->xfer_func = xfer_func; - tpg->recalc_colors = true; -} - -static inline u32 tpg_g_xfer_func(const struct tpg_data *tpg) -{ - return tpg->xfer_func; -} - -static inline void tpg_s_quantization(struct tpg_data *tpg, u32 quantization) -{ - if (tpg->quantization == quantization) - return; - tpg->quantization = quantization; - tpg->recalc_colors = true; -} - -static inline u32 tpg_g_quantization(const struct tpg_data *tpg) -{ - return tpg->quantization; -} - -static inline unsigned tpg_g_buffers(const struct tpg_data *tpg) -{ - return tpg->buffers; -} - -static inline unsigned tpg_g_planes(const struct tpg_data *tpg) -{ - return tpg->interleaved ? 1 : tpg->planes; -} - -static inline bool tpg_g_interleaved(const struct tpg_data *tpg) -{ - return tpg->interleaved; -} - -static inline unsigned tpg_g_twopixelsize(const struct tpg_data *tpg, unsigned plane) -{ - return tpg->twopixelsize[plane]; -} - -static inline unsigned tpg_hdiv(const struct tpg_data *tpg, - unsigned plane, unsigned x) -{ - return ((x / tpg->hdownsampling[plane]) & tpg->hmask[plane]) * - tpg->twopixelsize[plane] / 2; -} - -static inline unsigned tpg_hscale(const struct tpg_data *tpg, unsigned x) -{ - return (x * tpg->scaled_width) / tpg->src_width; -} - -static inline unsigned tpg_hscale_div(const struct tpg_data *tpg, - unsigned plane, unsigned x) -{ - return tpg_hdiv(tpg, plane, tpg_hscale(tpg, x)); -} - -static inline unsigned tpg_g_bytesperline(const struct tpg_data *tpg, unsigned plane) -{ - return tpg->bytesperline[plane]; -} - -static inline void tpg_s_bytesperline(struct tpg_data *tpg, unsigned plane, unsigned bpl) -{ - unsigned p; - - if (tpg->buffers > 1) { - tpg->bytesperline[plane] = bpl; - return; - } - - for (p = 0; p < tpg_g_planes(tpg); p++) { - unsigned plane_w = bpl * tpg->twopixelsize[p] / tpg->twopixelsize[0]; - - tpg->bytesperline[p] = plane_w / tpg->hdownsampling[p]; - } - if (tpg_g_interleaved(tpg)) - tpg->bytesperline[1] = tpg->bytesperline[0]; -} - - -static inline unsigned tpg_g_line_width(const struct tpg_data *tpg, unsigned plane) -{ - unsigned w = 0; - unsigned p; - - if (tpg->buffers > 1) - return tpg_g_bytesperline(tpg, plane); - for (p = 0; p < tpg_g_planes(tpg); p++) { - unsigned plane_w = tpg_g_bytesperline(tpg, p); - - w += plane_w / tpg->vdownsampling[p]; - } - return w; -} - -static inline unsigned tpg_calc_line_width(const struct tpg_data *tpg, - unsigned plane, unsigned bpl) -{ - unsigned w = 0; - unsigned p; - - if (tpg->buffers > 1) - return bpl; - for (p = 0; p < tpg_g_planes(tpg); p++) { - unsigned plane_w = bpl * tpg->twopixelsize[p] / tpg->twopixelsize[0]; - - plane_w /= tpg->hdownsampling[p]; - w += plane_w / tpg->vdownsampling[p]; - } - return w; -} - -static inline unsigned tpg_calc_plane_size(const struct tpg_data *tpg, unsigned plane) -{ - if (plane >= tpg_g_planes(tpg)) - return 0; - - return tpg_g_bytesperline(tpg, plane) * tpg->buf_height / - tpg->vdownsampling[plane]; -} - -static inline void tpg_s_buf_height(struct tpg_data *tpg, unsigned h) -{ - tpg->buf_height = h; -} - -static inline void tpg_s_field(struct tpg_data *tpg, unsigned field, bool alternate) -{ - tpg->field = field; - tpg->field_alternate = alternate; -} - -static inline void tpg_s_perc_fill(struct tpg_data *tpg, - unsigned perc_fill) -{ - tpg->perc_fill = perc_fill; -} - -static inline unsigned tpg_g_perc_fill(const struct tpg_data *tpg) -{ - return tpg->perc_fill; -} - -static inline void tpg_s_perc_fill_blank(struct tpg_data *tpg, - bool perc_fill_blank) -{ - tpg->perc_fill_blank = perc_fill_blank; -} - -static inline void tpg_s_video_aspect(struct tpg_data *tpg, - enum tpg_video_aspect vid_aspect) -{ - if (tpg->vid_aspect == vid_aspect) - return; - tpg->vid_aspect = vid_aspect; - tpg->recalc_square_border = true; -} - -static inline enum tpg_video_aspect tpg_g_video_aspect(const struct tpg_data *tpg) -{ - return tpg->vid_aspect; -} - -static inline void tpg_s_pixel_aspect(struct tpg_data *tpg, - enum tpg_pixel_aspect pix_aspect) -{ - if (tpg->pix_aspect == pix_aspect) - return; - tpg->pix_aspect = pix_aspect; - tpg->recalc_square_border = true; -} - -static inline void tpg_s_show_border(struct tpg_data *tpg, - bool show_border) -{ - tpg->show_border = show_border; -} - -static inline void tpg_s_show_square(struct tpg_data *tpg, - bool show_square) -{ - tpg->show_square = show_square; -} - -static inline void tpg_s_insert_sav(struct tpg_data *tpg, bool insert_sav) -{ - tpg->insert_sav = insert_sav; -} - -static inline void tpg_s_insert_eav(struct tpg_data *tpg, bool insert_eav) -{ - tpg->insert_eav = insert_eav; -} - -void tpg_update_mv_step(struct tpg_data *tpg); - -static inline void tpg_s_mv_hor_mode(struct tpg_data *tpg, - enum tpg_move_mode mv_hor_mode) -{ - tpg->mv_hor_mode = mv_hor_mode; - tpg_update_mv_step(tpg); -} - -static inline void tpg_s_mv_vert_mode(struct tpg_data *tpg, - enum tpg_move_mode mv_vert_mode) -{ - tpg->mv_vert_mode = mv_vert_mode; - tpg_update_mv_step(tpg); -} - -static inline void tpg_init_mv_count(struct tpg_data *tpg) -{ - tpg->mv_hor_count = tpg->mv_vert_count = 0; -} - -static inline void tpg_update_mv_count(struct tpg_data *tpg, bool frame_is_field) -{ - tpg->mv_hor_count += tpg->mv_hor_step * (frame_is_field ? 1 : 2); - tpg->mv_vert_count += tpg->mv_vert_step * (frame_is_field ? 1 : 2); -} - -static inline void tpg_s_hflip(struct tpg_data *tpg, bool hflip) -{ - if (tpg->hflip == hflip) - return; - tpg->hflip = hflip; - tpg_update_mv_step(tpg); - tpg->recalc_lines = true; -} - -static inline bool tpg_g_hflip(const struct tpg_data *tpg) -{ - return tpg->hflip; -} - -static inline void tpg_s_vflip(struct tpg_data *tpg, bool vflip) -{ - tpg->vflip = vflip; -} - -static inline bool tpg_g_vflip(const struct tpg_data *tpg) -{ - return tpg->vflip; -} - -static inline bool tpg_pattern_is_static(const struct tpg_data *tpg) -{ - return tpg->pattern != TPG_PAT_NOISE && - tpg->mv_hor_mode == TPG_MOVE_NONE && - tpg->mv_vert_mode == TPG_MOVE_NONE; -} - -#endif -- cgit From b29fd5639c8a7d2f419f0aea5a36f9a58027b29d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 9 Oct 2017 06:10:28 -0400 Subject: media: v4l2-tpg.h: rename color structs The color structs right now are just "color" and "color16". That may lead into conflicts, and don't define precisely what they meant. As those are used by two drivers (vivid and vimc), this is even on a somewhat public header! So rename them to: color -> tpg_rbg_color8 color16 -> tpg_rbg_color16 Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/tpg/v4l2-tpg.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include/media') diff --git a/include/media/tpg/v4l2-tpg.h b/include/media/tpg/v4l2-tpg.h index 028d81182011..bc0b38440719 100644 --- a/include/media/tpg/v4l2-tpg.h +++ b/include/media/tpg/v4l2-tpg.h @@ -27,11 +27,11 @@ #include #include -struct color { +struct tpg_rbg_color8 { unsigned char r, g, b; }; -struct color16 { +struct tpg_rbg_color16 { int r, g, b; }; @@ -65,10 +65,10 @@ enum tpg_color { TPG_COLOR_MAX = TPG_COLOR_RAMP + 256 }; -extern const struct color tpg_colors[TPG_COLOR_MAX]; +extern const struct tpg_rbg_color8 tpg_colors[TPG_COLOR_MAX]; extern const unsigned short tpg_rec709_to_linear[255 * 16 + 1]; extern const unsigned short tpg_linear_to_rec709[255 * 16 + 1]; -extern const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1] +extern const struct tpg_rbg_color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1] [V4L2_XFER_FUNC_SMPTE2084 + 1] [TPG_COLOR_CSC_BLACK + 1]; enum tpg_pattern { -- cgit From 43feabdbcc52297917720273a731bd5fe788d972 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 9 Oct 2017 06:20:48 -0400 Subject: media: v4l2-tpg: use __u16 instead of int for struct tpg_rbg_color16 Despite the struct says "color16", it was actually using 32 bits for each color. Fix it. Suggested-by: Hans Verkuil Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/tpg/v4l2-tpg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/tpg/v4l2-tpg.h b/include/media/tpg/v4l2-tpg.h index bc0b38440719..823fadede7bf 100644 --- a/include/media/tpg/v4l2-tpg.h +++ b/include/media/tpg/v4l2-tpg.h @@ -32,7 +32,7 @@ struct tpg_rbg_color8 { }; struct tpg_rbg_color16 { - int r, g, b; + __u16 r, g, b; }; enum tpg_color { -- cgit From 0722ef82e573bce8254f69ff314ef0edbfd1c1f0 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 6 Oct 2017 09:54:05 -0400 Subject: media: v4l2-subdev: fix a typo ownner -> owner Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-subdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index a6a9e54388e2..8040db3d62bf 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -788,7 +788,7 @@ struct v4l2_subdev_platform_data { * @list: List of sub-devices * @owner: The owner is the same as the driver's &struct device owner. * @owner_v4l2_dev: true if the &sd->owner matches the owner of @v4l2_dev->dev - * ownner. Initialized by v4l2_device_register_subdev(). + * owner. Initialized by v4l2_device_register_subdev(). * @flags: subdev flags. Can be: * %V4L2_SUBDEV_FL_IS_I2C - Set this flag if this subdev is a i2c device; * %V4L2_SUBDEV_FL_IS_SPI - Set this flag if this subdev is a spi device; -- cgit From 4eb2f55728abbe5adb526a9553752d0add5a9550 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 5 Oct 2017 16:17:27 -0400 Subject: media: v4l2-subdev: better document IO pin configuration flags Convert V4L2_SUBDEV_IO_PIN_* to enums, use BIT() and document via kernel-doc. Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-subdev.h | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 8040db3d62bf..3b80e8537198 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -108,22 +108,31 @@ struct v4l2_decode_vbi_line { * not yet implemented) since ops provide proper type-checking. */ -/* Subdevice external IO pin configuration */ -#define V4L2_SUBDEV_IO_PIN_DISABLE (1 << 0) /* ENABLE assumed */ -#define V4L2_SUBDEV_IO_PIN_OUTPUT (1 << 1) -#define V4L2_SUBDEV_IO_PIN_INPUT (1 << 2) -#define V4L2_SUBDEV_IO_PIN_SET_VALUE (1 << 3) /* Set output value */ -#define V4L2_SUBDEV_IO_PIN_ACTIVE_LOW (1 << 4) /* ACTIVE HIGH assumed */ +/** + * enum v4l2_subdev_io_pin_bits - Subdevice external IO pin configuration + * bits + * + * @V4L2_SUBDEV_IO_PIN_DISABLE: disables a pin config. ENABLE assumed. + * @V4L2_SUBDEV_IO_PIN_OUTPUT: set it if pin is an output. + * @V4L2_SUBDEV_IO_PIN_INPUT: set it if pin is an input. + * @V4L2_SUBDEV_IO_PIN_SET_VALUE: to set the output value via + * &struct v4l2_subdev_io_pin_config->value. + * @V4L2_SUBDEV_IO_PIN_ACTIVE_LOW: pin active is bit 0. + * Otherwise, ACTIVE HIGH is assumed. + */ +enum v4l2_subdev_io_pin_bits { + V4L2_SUBDEV_IO_PIN_DISABLE = 0, + V4L2_SUBDEV_IO_PIN_OUTPUT = 1, + V4L2_SUBDEV_IO_PIN_INPUT = 2, + V4L2_SUBDEV_IO_PIN_SET_VALUE = 3, + V4L2_SUBDEV_IO_PIN_ACTIVE_LOW = 4, +}; /** * struct v4l2_subdev_io_pin_config - Subdevice external IO pin configuration * - * @flags: bitmask with flags for this pin's config: - * %V4L2_SUBDEV_IO_PIN_DISABLE - disables a pin config, - * %V4L2_SUBDEV_IO_PIN_OUTPUT - if pin is an output, - * %V4L2_SUBDEV_IO_PIN_INPUT - if pin is an input, - * %V4L2_SUBDEV_IO_PIN_SET_VALUE - to set the output value via @value - * and %V4L2_SUBDEV_IO_PIN_ACTIVE_LOW - if active is 0. + * @flags: bitmask with flags for this pin's config, whose bits are defined by + * &enum v4l2_subdev_io_pin_bits. * @pin: Chip external IO pin to configure * @function: Internal signal pad/function to route to IO pin * @value: Initial value for pin - e.g. GPIO output value -- cgit From bb92895a1c68569055106a6d9bf5c330e5e6a371 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 5 Oct 2017 16:32:30 -0400 Subject: media: v4l2-subdev: convert frame description to enum As kernel-doc doesn't support documenting #define values, and using enum makes easier to identify where the values are used, convert V4L2_MBUS_FRAME_DESC_FL_* to enum, and use BIT() macro. While here, fix the description at v4l2_mbus_frame_desc_entry, in order to match what's described for V4L2_MBUS_FRAME_DESC_FL_LEN_MAX. Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-subdev.h | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 3b80e8537198..71b8ff4b2e0e 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -313,25 +313,32 @@ struct v4l2_subdev_audio_ops { int (*s_stream)(struct v4l2_subdev *sd, int enable); }; -/* Indicates the @length field specifies maximum data length. */ -#define V4L2_MBUS_FRAME_DESC_FL_LEN_MAX (1U << 0) -/* - * Indicates that the format does not have line offsets, i.e. the - * receiver should use 1D DMA. +/** + * enum v4l2_mbus_frame_desc_entry - media bus frame description flags + * + * @V4L2_MBUS_FRAME_DESC_FL_LEN_MAX: + * Indicates that &struct v4l2_mbus_frame_desc_entry->length field + * specifies maximum data length. + * @V4L2_MBUS_FRAME_DESC_FL_BLOB: + * Indicates that the format does not have line offsets, i.e. + * the receiver should use 1D DMA. */ -#define V4L2_MBUS_FRAME_DESC_FL_BLOB (1U << 1) +enum v4l2_mbus_frame_desc_flags { + V4L2_MBUS_FRAME_DESC_FL_LEN_MAX = BIT(0), + V4L2_MBUS_FRAME_DESC_FL_BLOB = BIT(1), +}; /** * struct v4l2_mbus_frame_desc_entry - media bus frame description structure * - * @flags: bitmask flags: %V4L2_MBUS_FRAME_DESC_FL_LEN_MAX and - * %V4L2_MBUS_FRAME_DESC_FL_BLOB. - * @pixelcode: media bus pixel code, valid if FRAME_DESC_FL_BLOB is not set - * @length: number of octets per frame, valid if V4L2_MBUS_FRAME_DESC_FL_BLOB - * is set + * @flags: bitmask flags, as defined by &enum v4l2_mbus_frame_desc_flags. + * @pixelcode: media bus pixel code, valid if @flags + * %FRAME_DESC_FL_BLOB is not set. + * @length: number of octets per frame, valid if @flags + * %V4L2_MBUS_FRAME_DESC_FL_LEN_MAX is set. */ struct v4l2_mbus_frame_desc_entry { - u16 flags; + enum v4l2_mbus_frame_desc_flags flags; u32 pixelcode; u32 length; }; -- cgit From 991232a929c1c93b3443fff2b228863646aae5e6 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 9 Oct 2017 05:31:49 -0400 Subject: media: vb2-core: fix descriptions for VB2-only functions When we split VB2 into an independent streaming module and a V4L2 one, some vb2-core functions started to have a wrong description: they're meant to be used only by the API-specific parts of VB2, like vb2-v4l2, as the functions that V4L2 drivers should use are all under videobuf2-v4l2.h. Correct their descriptions. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/videobuf2-core.h | 89 +++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 40 deletions(-) (limited to 'include/media') diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index ce795cd0a7cc..f3ee4c7c2fb3 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -651,12 +651,14 @@ int vb2_wait_for_all_buffers(struct vb2_queue *q); * @index: id number of the buffer. * @pb: buffer struct passed from userspace. * - * Should be called from &v4l2_ioctl_ops->vidioc_querybuf ioctl handler - * in driver. + * Videobuf2 core helper to implement VIDIOC_QUERYBUF() operation. It is called + * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``. * * The passed buffer should have been verified. * * This function fills the relevant information for the userspace. + * + * Return: returns zero on success; an error code otherwise. */ void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb); @@ -666,27 +668,26 @@ void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb); * @memory: memory type, as defined by &enum vb2_memory. * @count: requested buffer count. * - * Should be called from &v4l2_ioctl_ops->vidioc_reqbufs ioctl - * handler of a driver. + * Videobuf2 core helper to implement VIDIOC_REQBUF() operation. It is called + * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``. * * This function: * - * #) verifies streaming parameters passed from the userspace, - * #) sets up the queue, + * #) verifies streaming parameters passed from the userspace; + * #) sets up the queue; * #) negotiates number of buffers and planes per buffer with the driver - * to be used during streaming, + * to be used during streaming; * #) allocates internal buffer structures (&struct vb2_buffer), according to - * the agreed parameters, + * the agreed parameters; * #) for MMAP memory type, allocates actual video memory, using the - * memory handling/allocation routines provided during queue initialization + * memory handling/allocation routines provided during queue initialization. * * If req->count is 0, all the memory will be freed instead. * * If the queue has been allocated previously by a previous vb2_core_reqbufs() * call and the queue is not busy, memory will be reallocated. * - * The return values from this function are intended to be directly returned - * from &v4l2_ioctl_ops->vidioc_reqbufs handler in driver. + * Return: returns zero on success; an error code otherwise. */ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, unsigned int *count); @@ -699,17 +700,17 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, * @requested_planes: number of planes requested. * @requested_sizes: array with the size of the planes. * - * Should be called from &v4l2_ioctl_ops->vidioc_create_bufs ioctl handler - * of a driver. + * Videobuf2 core helper to implement VIDIOC_CREATE_BUFS() operation. It is + * called internally by VB2 by an API-specific handler, like + * ``videobuf2-v4l2.h``. * * This function: * - * #) verifies parameter sanity - * #) calls the &vb2_ops->queue_setup queue operation - * #) performs any necessary memory allocations + * #) verifies parameter sanity; + * #) calls the &vb2_ops->queue_setup queue operation; + * #) performs any necessary memory allocations. * - * Return: the return values from this function are intended to be directly - * returned from &v4l2_ioctl_ops->vidioc_create_bufs handler in driver. + * Return: returns zero on success; an error code otherwise. */ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, unsigned int *count, unsigned int requested_planes, @@ -723,16 +724,17 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, * @pb: buffer structure passed from userspace to * &v4l2_ioctl_ops->vidioc_prepare_buf handler in driver. * - * Should be called from &v4l2_ioctl_ops->vidioc_prepare_buf ioctl handler - * of a driver. + * Videobuf2 core helper to implement VIDIOC_PREPARE_BUF() operation. It is + * called internally by VB2 by an API-specific handler, like + * ``videobuf2-v4l2.h``. * * The passed buffer should have been verified. * - * This function calls buf_prepare callback in the driver (if provided), - * in which driver-specific buffer initialization can be performed, + * This function calls vb2_ops->buf_prepare callback in the driver + * (if provided), in which driver-specific buffer initialization can + * be performed. * - * The return values from this function are intended to be directly returned - * from v4l2_ioctl_ops->vidioc_prepare_buf handler in driver. + * Return: returns zero on success; an error code otherwise. */ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); @@ -744,18 +746,18 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); * @pb: buffer structure passed from userspace to * v4l2_ioctl_ops->vidioc_qbuf handler in driver * - * Should be called from v4l2_ioctl_ops->vidioc_qbuf ioctl handler of a driver. - * The passed buffer should have been verified. + * Videobuf2 core helper to implement VIDIOC_QBUF() operation. It is called + * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``. * * This function: * - * #) if necessary, calls buf_prepare callback in the driver (if provided), in - * which driver-specific buffer initialization can be performed, + * #) if necessary, calls &vb2_ops->buf_prepare callback in the driver + * (if provided), in which driver-specific buffer initialization can + * be performed; * #) if streaming is on, queues the buffer in driver by the means of * &vb2_ops->buf_queue callback for processing. * - * The return values from this function are intended to be directly returned - * from v4l2_ioctl_ops->vidioc_qbuf handler in driver. + * Return: returns zero on success; an error code otherwise. */ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb); @@ -769,8 +771,8 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb); * buffers ready for dequeuing are present. Normally the driver * would be passing (file->f_flags & O_NONBLOCK) here. * - * Should be called from v4l2_ioctl_ops->vidioc_dqbuf ioctl handler of a driver. - * The passed buffer should have been verified. + * Videobuf2 core helper to implement VIDIOC_DQBUF() operation. It is called + * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``. * * This function: * @@ -780,8 +782,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb); * #) the buffer struct members are filled with relevant information for * the userspace. * - * The return values from this function are intended to be directly returned - * from v4l2_ioctl_ops->vidioc_dqbuf handler in driver. + * Return: returns zero on success; an error code otherwise. */ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb, bool nonblocking); @@ -793,8 +794,10 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb, * @type: type of the queue to be started. * For V4L2, this is defined by &enum v4l2_buf_type type. * - * Should be called from &v4l2_ioctl_ops->vidioc_streamon ioctl handler of - * a driver. + * Videobuf2 core helper to implement VIDIOC_STREAMON() operation. It is called + * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``. + * + * Return: returns zero on success; an error code otherwise. */ int vb2_core_streamon(struct vb2_queue *q, unsigned int type); @@ -805,8 +808,11 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type); * @type: type of the queue to be started. * For V4L2, this is defined by &enum v4l2_buf_type type. * - * Should be called from &v4l2_ioctl_ops->vidioc_streamon ioctl handler of - * a driver. + * Videobuf2 core helper to implement VIDIOC_STREAMOFF() operation. It is + * called internally by VB2 by an API-specific handler, like + * ``videobuf2-v4l2.h``. + * + * Return: returns zero on success; an error code otherwise. */ int vb2_core_streamoff(struct vb2_queue *q, unsigned int type); @@ -823,8 +829,11 @@ int vb2_core_streamoff(struct vb2_queue *q, unsigned int type); * Currently, the only used flag is %O_CLOEXEC. * is supported, refer to manual of open syscall for more details. * - * The return values from this function are intended to be directly returned - * from v4l2_ioctl_ops->vidioc_expbuf handler in driver. + * + * Videobuf2 core helper to implement VIDIOC_EXPBUF() operation. It is called + * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``. + * + * Return: returns zero on success; an error code otherwise. */ int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type, unsigned int index, unsigned int plane, unsigned int flags); -- cgit From 3090a1915e9865d23f2aa76cc01e5b5f9cb6d7e3 Mon Sep 17 00:00:00 2001 From: Simon Shields Date: Mon, 27 Nov 2017 08:12:41 -0500 Subject: media: exynos4-is: Check pipe is valid before calling subdev If the subdev is not yet present (probably because the subdev module has not yet been loaded), the pipe will be NULL. Make sure that this is not the case before attempting to call the op. Signed-off-by: Simon Shields Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- include/media/drv-intf/exynos-fimc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/drv-intf/exynos-fimc.h b/include/media/drv-intf/exynos-fimc.h index 69bcd2a07d5c..f9c64338841f 100644 --- a/include/media/drv-intf/exynos-fimc.h +++ b/include/media/drv-intf/exynos-fimc.h @@ -155,7 +155,8 @@ static inline struct exynos_video_entity *vdev_to_exynos_video_entity( } #define fimc_pipeline_call(ent, op, args...) \ - (!(ent) ? -ENOENT : (((ent)->pipe->ops && (ent)->pipe->ops->op) ? \ + ((!(ent) || !(ent)->pipe) ? -ENOENT : \ + (((ent)->pipe->ops && (ent)->pipe->ops->op) ? \ (ent)->pipe->ops->op(((ent)->pipe), ##args) : -ENOIOCTLCMD)) \ #endif /* S5P_FIMC_H_ */ -- cgit From fada1935590f66dc6784981e0d557ca09013c847 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 28 Dec 2017 13:03:51 -0500 Subject: media: move dvb kAPI headers to include/media Except for DVB, all media kAPI headers are at include/media. Move the headers to it. Signed-off-by: Mauro Carvalho Chehab --- include/media/demux.h | 589 ++++++++++++++++++++++++++++++ include/media/dmxdev.h | 210 +++++++++++ include/media/dvb-usb-ids.h | 424 ++++++++++++++++++++++ include/media/dvb_ca_en50221.h | 142 ++++++++ include/media/dvb_demux.h | 350 ++++++++++++++++++ include/media/dvb_frontend.h | 795 +++++++++++++++++++++++++++++++++++++++++ include/media/dvb_math.h | 66 ++++ include/media/dvb_net.h | 93 +++++ include/media/dvb_ringbuffer.h | 280 +++++++++++++++ include/media/dvb_vb2.h | 96 +++++ include/media/dvbdev.h | 407 +++++++++++++++++++++ include/media/videobuf-dvb.h | 10 +- include/media/videobuf2-dvb.h | 11 +- 13 files changed, 3462 insertions(+), 11 deletions(-) create mode 100644 include/media/demux.h create mode 100644 include/media/dmxdev.h create mode 100644 include/media/dvb-usb-ids.h create mode 100644 include/media/dvb_ca_en50221.h create mode 100644 include/media/dvb_demux.h create mode 100644 include/media/dvb_frontend.h create mode 100644 include/media/dvb_math.h create mode 100644 include/media/dvb_net.h create mode 100644 include/media/dvb_ringbuffer.h create mode 100644 include/media/dvb_vb2.h create mode 100644 include/media/dvbdev.h (limited to 'include/media') diff --git a/include/media/demux.h b/include/media/demux.h new file mode 100644 index 000000000000..c4df6cee48e6 --- /dev/null +++ b/include/media/demux.h @@ -0,0 +1,589 @@ +/* + * demux.h + * + * The Kernel Digital TV Demux kABI defines a driver-internal interface for + * registering low-level, hardware specific driver to a hardware independent + * demux layer. + * + * Copyright (c) 2002 Convergence GmbH + * + * based on code: + * Copyright (c) 2000 Nokia Research Center + * Tampere, FINLAND + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef __DEMUX_H +#define __DEMUX_H + +#include +#include +#include +#include +#include + +/* + * Common definitions + */ + +/* + * DMX_MAX_FILTER_SIZE: Maximum length (in bytes) of a section/PES filter. + */ + +#ifndef DMX_MAX_FILTER_SIZE +#define DMX_MAX_FILTER_SIZE 18 +#endif + +/* + * DMX_MAX_SECFEED_SIZE: Maximum length (in bytes) of a private section feed + * filter. + */ + +#ifndef DMX_MAX_SECTION_SIZE +#define DMX_MAX_SECTION_SIZE 4096 +#endif +#ifndef DMX_MAX_SECFEED_SIZE +#define DMX_MAX_SECFEED_SIZE (DMX_MAX_SECTION_SIZE + 188) +#endif + +/* + * TS packet reception + */ + +/** + * enum ts_filter_type - filter type bitmap for dmx_ts_feed.set\(\) + * + * @TS_PACKET: Send TS packets (188 bytes) to callback (default). + * @TS_PAYLOAD_ONLY: In case TS_PACKET is set, only send the TS payload + * (<=184 bytes per packet) to callback + * @TS_DECODER: Send stream to built-in decoder (if present). + * @TS_DEMUX: In case TS_PACKET is set, send the TS to the demux + * device, not to the dvr device + */ +enum ts_filter_type { + TS_PACKET = 1, + TS_PAYLOAD_ONLY = 2, + TS_DECODER = 4, + TS_DEMUX = 8, +}; + +/** + * struct dmx_ts_feed - Structure that contains a TS feed filter + * + * @is_filtering: Set to non-zero when filtering in progress + * @parent: pointer to struct dmx_demux + * @priv: pointer to private data of the API client + * @set: sets the TS filter + * @start_filtering: starts TS filtering + * @stop_filtering: stops TS filtering + * + * A TS feed is typically mapped to a hardware PID filter on the demux chip. + * Using this API, the client can set the filtering properties to start/stop + * filtering TS packets on a particular TS feed. + */ +struct dmx_ts_feed { + int is_filtering; + struct dmx_demux *parent; + void *priv; + int (*set)(struct dmx_ts_feed *feed, + u16 pid, + int type, + enum dmx_ts_pes pes_type, + ktime_t timeout); + int (*start_filtering)(struct dmx_ts_feed *feed); + int (*stop_filtering)(struct dmx_ts_feed *feed); +}; + +/* + * Section reception + */ + +/** + * struct dmx_section_filter - Structure that describes a section filter + * + * @filter_value: Contains up to 16 bytes (128 bits) of the TS section header + * that will be matched by the section filter + * @filter_mask: Contains a 16 bytes (128 bits) filter mask with the bits + * specified by @filter_value that will be used on the filter + * match logic. + * @filter_mode: Contains a 16 bytes (128 bits) filter mode. + * @parent: Pointer to struct dmx_section_feed. + * @priv: Pointer to private data of the API client. + * + * + * The @filter_mask controls which bits of @filter_value are compared with + * the section headers/payload. On a binary value of 1 in filter_mask, the + * corresponding bits are compared. The filter only accepts sections that are + * equal to filter_value in all the tested bit positions. + */ +struct dmx_section_filter { + u8 filter_value[DMX_MAX_FILTER_SIZE]; + u8 filter_mask[DMX_MAX_FILTER_SIZE]; + u8 filter_mode[DMX_MAX_FILTER_SIZE]; + struct dmx_section_feed *parent; /* Back-pointer */ + void *priv; /* Pointer to private data of the API client */ +}; + +/** + * struct dmx_section_feed - Structure that contains a section feed filter + * + * @is_filtering: Set to non-zero when filtering in progress + * @parent: pointer to struct dmx_demux + * @priv: pointer to private data of the API client + * @check_crc: If non-zero, check the CRC values of filtered sections. + * @set: sets the section filter + * @allocate_filter: This function is used to allocate a section filter on + * the demux. It should only be called when no filtering + * is in progress on this section feed. If a filter cannot + * be allocated, the function fails with -ENOSPC. + * @release_filter: This function releases all the resources of a + * previously allocated section filter. The function + * should not be called while filtering is in progress + * on this section feed. After calling this function, + * the caller should not try to dereference the filter + * pointer. + * @start_filtering: starts section filtering + * @stop_filtering: stops section filtering + * + * A TS feed is typically mapped to a hardware PID filter on the demux chip. + * Using this API, the client can set the filtering properties to start/stop + * filtering TS packets on a particular TS feed. + */ +struct dmx_section_feed { + int is_filtering; + struct dmx_demux *parent; + void *priv; + + int check_crc; + + /* private: Used internally at dvb_demux.c */ + u32 crc_val; + + u8 *secbuf; + u8 secbuf_base[DMX_MAX_SECFEED_SIZE]; + u16 secbufp, seclen, tsfeedp; + + /* public: */ + int (*set)(struct dmx_section_feed *feed, + u16 pid, + int check_crc); + int (*allocate_filter)(struct dmx_section_feed *feed, + struct dmx_section_filter **filter); + int (*release_filter)(struct dmx_section_feed *feed, + struct dmx_section_filter *filter); + int (*start_filtering)(struct dmx_section_feed *feed); + int (*stop_filtering)(struct dmx_section_feed *feed); +}; + +/** + * typedef dmx_ts_cb - DVB demux TS filter callback function prototype + * + * @buffer1: Pointer to the start of the filtered TS packets. + * @buffer1_length: Length of the TS data in buffer1. + * @buffer2: Pointer to the tail of the filtered TS packets, or NULL. + * @buffer2_length: Length of the TS data in buffer2. + * @source: Indicates which TS feed is the source of the callback. + * + * This function callback prototype, provided by the client of the demux API, + * is called from the demux code. The function is only called when filtering + * on a TS feed has been enabled using the start_filtering\(\) function at + * the &dmx_demux. + * Any TS packets that match the filter settings are copied to a circular + * buffer. The filtered TS packets are delivered to the client using this + * callback function. + * It is expected that the @buffer1 and @buffer2 callback parameters point to + * addresses within the circular buffer, but other implementations are also + * possible. Note that the called party should not try to free the memory + * the @buffer1 and @buffer2 parameters point to. + * + * When this function is called, the @buffer1 parameter typically points to + * the start of the first undelivered TS packet within a circular buffer. + * The @buffer2 buffer parameter is normally NULL, except when the received + * TS packets have crossed the last address of the circular buffer and + * "wrapped" to the beginning of the buffer. In the latter case the @buffer1 + * parameter would contain an address within the circular buffer, while the + * @buffer2 parameter would contain the first address of the circular buffer. + * The number of bytes delivered with this function (i.e. @buffer1_length + + * @buffer2_length) is usually equal to the value of callback_length parameter + * given in the set() function, with one exception: if a timeout occurs before + * receiving callback_length bytes of TS data, any undelivered packets are + * immediately delivered to the client by calling this function. The timeout + * duration is controlled by the set() function in the TS Feed API. + * + * If a TS packet is received with errors that could not be fixed by the + * TS-level forward error correction (FEC), the Transport_error_indicator + * flag of the TS packet header should be set. The TS packet should not be + * discarded, as the error can possibly be corrected by a higher layer + * protocol. If the called party is slow in processing the callback, it + * is possible that the circular buffer eventually fills up. If this happens, + * the demux driver should discard any TS packets received while the buffer + * is full and return -EOVERFLOW. + * + * The type of data returned to the callback can be selected by the + * &dmx_ts_feed.@set function. The type parameter decides if the raw + * TS packet (TS_PACKET) or just the payload (TS_PACKET|TS_PAYLOAD_ONLY) + * should be returned. If additionally the TS_DECODER bit is set the stream + * will also be sent to the hardware MPEG decoder. + * + * Return: + * + * - 0, on success; + * + * - -EOVERFLOW, on buffer overflow. + */ +typedef int (*dmx_ts_cb)(const u8 *buffer1, + size_t buffer1_length, + const u8 *buffer2, + size_t buffer2_length, + struct dmx_ts_feed *source); + +/** + * typedef dmx_section_cb - DVB demux TS filter callback function prototype + * + * @buffer1: Pointer to the start of the filtered section, e.g. + * within the circular buffer of the demux driver. + * @buffer1_len: Length of the filtered section data in @buffer1, + * including headers and CRC. + * @buffer2: Pointer to the tail of the filtered section data, + * or NULL. Useful to handle the wrapping of a + * circular buffer. + * @buffer2_len: Length of the filtered section data in @buffer2, + * including headers and CRC. + * @source: Indicates which section feed is the source of the + * callback. + * + * This function callback prototype, provided by the client of the demux API, + * is called from the demux code. The function is only called when + * filtering of sections has been enabled using the function + * &dmx_ts_feed.@start_filtering. When the demux driver has received a + * complete section that matches at least one section filter, the client + * is notified via this callback function. Normally this function is called + * for each received section; however, it is also possible to deliver + * multiple sections with one callback, for example when the system load + * is high. If an error occurs while receiving a section, this + * function should be called with the corresponding error type set in the + * success field, whether or not there is data to deliver. The Section Feed + * implementation should maintain a circular buffer for received sections. + * However, this is not necessary if the Section Feed API is implemented as + * a client of the TS Feed API, because the TS Feed implementation then + * buffers the received data. The size of the circular buffer can be + * configured using the &dmx_ts_feed.@set function in the Section Feed API. + * If there is no room in the circular buffer when a new section is received, + * the section must be discarded. If this happens, the value of the success + * parameter should be DMX_OVERRUN_ERROR on the next callback. + */ +typedef int (*dmx_section_cb)(const u8 *buffer1, + size_t buffer1_len, + const u8 *buffer2, + size_t buffer2_len, + struct dmx_section_filter *source); + +/* + * DVB Front-End + */ + +/** + * enum dmx_frontend_source - Used to identify the type of frontend + * + * @DMX_MEMORY_FE: The source of the demux is memory. It means that + * the MPEG-TS to be filtered comes from userspace, + * via write() syscall. + * + * @DMX_FRONTEND_0: The source of the demux is a frontend connected + * to the demux. + */ +enum dmx_frontend_source { + DMX_MEMORY_FE, + DMX_FRONTEND_0, +}; + +/** + * struct dmx_frontend - Structure that lists the frontends associated with + * a demux + * + * @connectivity_list: List of front-ends that can be connected to a + * particular demux; + * @source: Type of the frontend. + * + * FIXME: this structure should likely be replaced soon by some + * media-controller based logic. + */ +struct dmx_frontend { + struct list_head connectivity_list; + enum dmx_frontend_source source; +}; + +/* + * MPEG-2 TS Demux + */ + +/** + * enum dmx_demux_caps - MPEG-2 TS Demux capabilities bitmap + * + * @DMX_TS_FILTERING: set if TS filtering is supported; + * @DMX_SECTION_FILTERING: set if section filtering is supported; + * @DMX_MEMORY_BASED_FILTERING: set if write() available. + * + * Those flags are OR'ed in the &dmx_demux.capabilities field + */ +enum dmx_demux_caps { + DMX_TS_FILTERING = 1, + DMX_SECTION_FILTERING = 4, + DMX_MEMORY_BASED_FILTERING = 8, +}; + +/* + * Demux resource type identifier. + */ + +/** + * DMX_FE_ENTRY - Casts elements in the list of registered + * front-ends from the generic type struct list_head + * to the type * struct dmx_frontend + * + * @list: list of struct dmx_frontend + */ +#define DMX_FE_ENTRY(list) \ + list_entry(list, struct dmx_frontend, connectivity_list) + +/** + * struct dmx_demux - Structure that contains the demux capabilities and + * callbacks. + * + * @capabilities: Bitfield of capability flags. + * + * @frontend: Front-end connected to the demux + * + * @priv: Pointer to private data of the API client + * + * @open: This function reserves the demux for use by the caller and, if + * necessary, initializes the demux. When the demux is no longer needed, + * the function @close should be called. It should be possible for + * multiple clients to access the demux at the same time. Thus, the + * function implementation should increment the demux usage count when + * @open is called and decrement it when @close is called. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * It returns: + * 0 on success; + * -EUSERS, if maximum usage count was reached; + * -EINVAL, on bad parameter. + * + * @close: This function reserves the demux for use by the caller and, if + * necessary, initializes the demux. When the demux is no longer needed, + * the function @close should be called. It should be possible for + * multiple clients to access the demux at the same time. Thus, the + * function implementation should increment the demux usage count when + * @open is called and decrement it when @close is called. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * It returns: + * 0 on success; + * -ENODEV, if demux was not in use (e. g. no users); + * -EINVAL, on bad parameter. + * + * @write: This function provides the demux driver with a memory buffer + * containing TS packets. Instead of receiving TS packets from the DVB + * front-end, the demux driver software will read packets from memory. + * Any clients of this demux with active TS, PES or Section filters will + * receive filtered data via the Demux callback API (see 0). The function + * returns when all the data in the buffer has been consumed by the demux. + * Demux hardware typically cannot read TS from memory. If this is the + * case, memory-based filtering has to be implemented entirely in software. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * The @buf function parameter contains a pointer to the TS data in + * kernel-space memory. + * The @count function parameter contains the length of the TS data. + * It returns: + * 0 on success; + * -ERESTARTSYS, if mutex lock was interrupted; + * -EINTR, if a signal handling is pending; + * -ENODEV, if demux was removed; + * -EINVAL, on bad parameter. + * + * @allocate_ts_feed: Allocates a new TS feed, which is used to filter the TS + * packets carrying a certain PID. The TS feed normally corresponds to a + * hardware PID filter on the demux chip. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * The @feed function parameter contains a pointer to the TS feed API and + * instance data. + * The @callback function parameter contains a pointer to the callback + * function for passing received TS packet. + * It returns: + * 0 on success; + * -ERESTARTSYS, if mutex lock was interrupted; + * -EBUSY, if no more TS feeds is available; + * -EINVAL, on bad parameter. + * + * @release_ts_feed: Releases the resources allocated with @allocate_ts_feed. + * Any filtering in progress on the TS feed should be stopped before + * calling this function. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * The @feed function parameter contains a pointer to the TS feed API and + * instance data. + * It returns: + * 0 on success; + * -EINVAL on bad parameter. + * + * @allocate_section_feed: Allocates a new section feed, i.e. a demux resource + * for filtering and receiving sections. On platforms with hardware + * support for section filtering, a section feed is directly mapped to + * the demux HW. On other platforms, TS packets are first PID filtered in + * hardware and a hardware section filter then emulated in software. The + * caller obtains an API pointer of type dmx_section_feed_t as an out + * parameter. Using this API the caller can set filtering parameters and + * start receiving sections. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * The @feed function parameter contains a pointer to the TS feed API and + * instance data. + * The @callback function parameter contains a pointer to the callback + * function for passing received TS packet. + * It returns: + * 0 on success; + * -EBUSY, if no more TS feeds is available; + * -EINVAL, on bad parameter. + * + * @release_section_feed: Releases the resources allocated with + * @allocate_section_feed, including allocated filters. Any filtering in + * progress on the section feed should be stopped before calling this + * function. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * The @feed function parameter contains a pointer to the TS feed API and + * instance data. + * It returns: + * 0 on success; + * -EINVAL, on bad parameter. + * + * @add_frontend: Registers a connectivity between a demux and a front-end, + * i.e., indicates that the demux can be connected via a call to + * @connect_frontend to use the given front-end as a TS source. The + * client of this function has to allocate dynamic or static memory for + * the frontend structure and initialize its fields before calling this + * function. This function is normally called during the driver + * initialization. The caller must not free the memory of the frontend + * struct before successfully calling @remove_frontend. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * The @frontend function parameter contains a pointer to the front-end + * instance data. + * It returns: + * 0 on success; + * -EINVAL, on bad parameter. + * + * @remove_frontend: Indicates that the given front-end, registered by a call + * to @add_frontend, can no longer be connected as a TS source by this + * demux. The function should be called when a front-end driver or a demux + * driver is removed from the system. If the front-end is in use, the + * function fails with the return value of -EBUSY. After successfully + * calling this function, the caller can free the memory of the frontend + * struct if it was dynamically allocated before the @add_frontend + * operation. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * The @frontend function parameter contains a pointer to the front-end + * instance data. + * It returns: + * 0 on success; + * -ENODEV, if the front-end was not found, + * -EINVAL, on bad parameter. + * + * @get_frontends: Provides the APIs of the front-ends that have been + * registered for this demux. Any of the front-ends obtained with this + * call can be used as a parameter for @connect_frontend. The include + * file demux.h contains the macro DMX_FE_ENTRY() for converting an + * element of the generic type struct &list_head * to the type + * struct &dmx_frontend *. The caller must not free the memory of any of + * the elements obtained via this function call. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * It returns a struct list_head pointer to the list of front-end + * interfaces, or NULL in the case of an empty list. + * + * @connect_frontend: Connects the TS output of the front-end to the input of + * the demux. A demux can only be connected to a front-end registered to + * the demux with the function @add_frontend. It may or may not be + * possible to connect multiple demuxes to the same front-end, depending + * on the capabilities of the HW platform. When not used, the front-end + * should be released by calling @disconnect_frontend. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * The @frontend function parameter contains a pointer to the front-end + * instance data. + * It returns: + * 0 on success; + * -EINVAL, on bad parameter. + * + * @disconnect_frontend: Disconnects the demux and a front-end previously + * connected by a @connect_frontend call. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * It returns: + * 0 on success; + * -EINVAL on bad parameter. + * + * @get_pes_pids: Get the PIDs for DMX_PES_AUDIO0, DMX_PES_VIDEO0, + * DMX_PES_TELETEXT0, DMX_PES_SUBTITLE0 and DMX_PES_PCR0. + * The @demux function parameter contains a pointer to the demux API and + * instance data. + * The @pids function parameter contains an array with five u16 elements + * where the PIDs will be stored. + * It returns: + * 0 on success; + * -EINVAL on bad parameter. + */ +struct dmx_demux { + enum dmx_demux_caps capabilities; + struct dmx_frontend *frontend; + void *priv; + int (*open)(struct dmx_demux *demux); + int (*close)(struct dmx_demux *demux); + int (*write)(struct dmx_demux *demux, const char __user *buf, + size_t count); + int (*allocate_ts_feed)(struct dmx_demux *demux, + struct dmx_ts_feed **feed, + dmx_ts_cb callback); + int (*release_ts_feed)(struct dmx_demux *demux, + struct dmx_ts_feed *feed); + int (*allocate_section_feed)(struct dmx_demux *demux, + struct dmx_section_feed **feed, + dmx_section_cb callback); + int (*release_section_feed)(struct dmx_demux *demux, + struct dmx_section_feed *feed); + int (*add_frontend)(struct dmx_demux *demux, + struct dmx_frontend *frontend); + int (*remove_frontend)(struct dmx_demux *demux, + struct dmx_frontend *frontend); + struct list_head *(*get_frontends)(struct dmx_demux *demux); + int (*connect_frontend)(struct dmx_demux *demux, + struct dmx_frontend *frontend); + int (*disconnect_frontend)(struct dmx_demux *demux); + + int (*get_pes_pids)(struct dmx_demux *demux, u16 *pids); + + /* private: */ + + /* + * Only used at av7110, to read some data from firmware. + * As this was never documented, we have no clue about what's + * there, and its usage on other drivers aren't encouraged. + */ + int (*get_stc)(struct dmx_demux *demux, unsigned int num, + u64 *stc, unsigned int *base); +}; + +#endif /* #ifndef __DEMUX_H */ diff --git a/include/media/dmxdev.h b/include/media/dmxdev.h new file mode 100644 index 000000000000..d5bef0da2e6e --- /dev/null +++ b/include/media/dmxdev.h @@ -0,0 +1,210 @@ +/* + * dmxdev.h + * + * Copyright (C) 2000 Ralph Metzler & Marcus Metzler + * for convergence integrated media GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _DMXDEV_H_ +#define _DMXDEV_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +/** + * enum dmxdev_type - type of demux filter type. + * + * @DMXDEV_TYPE_NONE: no filter set. + * @DMXDEV_TYPE_SEC: section filter. + * @DMXDEV_TYPE_PES: Program Elementary Stream (PES) filter. + */ +enum dmxdev_type { + DMXDEV_TYPE_NONE, + DMXDEV_TYPE_SEC, + DMXDEV_TYPE_PES, +}; + +/** + * enum dmxdev_state - state machine for the dmxdev. + * + * @DMXDEV_STATE_FREE: indicates that the filter is freed. + * @DMXDEV_STATE_ALLOCATED: indicates that the filter was allocated + * to be used. + * @DMXDEV_STATE_SET: indicates that the filter parameters are set. + * @DMXDEV_STATE_GO: indicates that the filter is running. + * @DMXDEV_STATE_DONE: indicates that a packet was already filtered + * and the filter is now disabled. + * Set only if %DMX_ONESHOT. See + * &dmx_sct_filter_params. + * @DMXDEV_STATE_TIMEDOUT: Indicates a timeout condition. + */ +enum dmxdev_state { + DMXDEV_STATE_FREE, + DMXDEV_STATE_ALLOCATED, + DMXDEV_STATE_SET, + DMXDEV_STATE_GO, + DMXDEV_STATE_DONE, + DMXDEV_STATE_TIMEDOUT +}; + +/** + * struct dmxdev_feed - digital TV dmxdev feed + * + * @pid: Program ID to be filtered + * @ts: pointer to &struct dmx_ts_feed + * @next: &struct list_head pointing to the next feed. + */ + +struct dmxdev_feed { + u16 pid; + struct dmx_ts_feed *ts; + struct list_head next; +}; + +/** + * struct dmxdev_filter - digital TV dmxdev filter + * + * @filter: a union describing a dmxdev filter. + * Currently used only for section filters. + * @filter.sec: a &struct dmx_section_filter pointer. + * For section filter only. + * @feed: a union describing a dmxdev feed. + * Depending on the filter type, it can be either + * @feed.ts or @feed.sec. + * @feed.ts: a &struct list_head list. + * For TS and PES feeds. + * @feed.sec: a &struct dmx_section_feed pointer. + * For section feed only. + * @params: a union describing dmxdev filter parameters. + * Depending on the filter type, it can be either + * @params.sec or @params.pes. + * @params.sec: a &struct dmx_sct_filter_params embedded struct. + * For section filter only. + * @params.pes: a &struct dmx_pes_filter_params embedded struct. + * For PES filter only. + * @type: type of the dmxdev filter, as defined by &enum dmxdev_type. + * @state: state of the dmxdev filter, as defined by &enum dmxdev_state. + * @dev: pointer to &struct dmxdev. + * @buffer: an embedded &struct dvb_ringbuffer buffer. + * @mutex: protects the access to &struct dmxdev_filter. + * @timer: &struct timer_list embedded timer, used to check for + * feed timeouts. + * Only for section filter. + * @todo: index for the @secheader. + * Only for section filter. + * @secheader: buffer cache to parse the section header. + * Only for section filter. + */ +struct dmxdev_filter { + union { + struct dmx_section_filter *sec; + } filter; + + union { + /* list of TS and PES feeds (struct dmxdev_feed) */ + struct list_head ts; + struct dmx_section_feed *sec; + } feed; + + union { + struct dmx_sct_filter_params sec; + struct dmx_pes_filter_params pes; + } params; + + enum dmxdev_type type; + enum dmxdev_state state; + struct dmxdev *dev; + struct dvb_ringbuffer buffer; + struct dvb_vb2_ctx vb2_ctx; + + struct mutex mutex; + + /* only for sections */ + struct timer_list timer; + int todo; + u8 secheader[3]; +}; + +/** + * struct dmxdev - Describes a digital TV demux device. + * + * @dvbdev: pointer to &struct dvb_device associated with + * the demux device node. + * @dvr_dvbdev: pointer to &struct dvb_device associated with + * the dvr device node. + * @filter: pointer to &struct dmxdev_filter. + * @demux: pointer to &struct dmx_demux. + * @filternum: number of filters. + * @capabilities: demux capabilities as defined by &enum dmx_demux_caps. + * @exit: flag to indicate that the demux is being released. + * @dvr_orig_fe: pointer to &struct dmx_frontend. + * @dvr_buffer: embedded &struct dvb_ringbuffer for DVB output. + * @mutex: protects the usage of this structure. + * @lock: protects access to &dmxdev->filter->data. + */ +struct dmxdev { + struct dvb_device *dvbdev; + struct dvb_device *dvr_dvbdev; + + struct dmxdev_filter *filter; + struct dmx_demux *demux; + + int filternum; + int capabilities; + + unsigned int exit:1; +#define DMXDEV_CAP_DUPLEX 1 + struct dmx_frontend *dvr_orig_fe; + + struct dvb_ringbuffer dvr_buffer; +#define DVR_BUFFER_SIZE (10*188*1024) + + struct dvb_vb2_ctx dvr_vb2_ctx; + + struct mutex mutex; + spinlock_t lock; +}; + +/** + * dvb_dmxdev_init - initializes a digital TV demux and registers both demux + * and DVR devices. + * + * @dmxdev: pointer to &struct dmxdev. + * @adap: pointer to &struct dvb_adapter. + */ +int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *adap); + +/** + * dvb_dmxdev_release - releases a digital TV demux and unregisters it. + * + * @dmxdev: pointer to &struct dmxdev. + */ +void dvb_dmxdev_release(struct dmxdev *dmxdev); + +#endif /* _DMXDEV_H_ */ diff --git a/include/media/dvb-usb-ids.h b/include/media/dvb-usb-ids.h new file mode 100644 index 000000000000..28e2be5c8a98 --- /dev/null +++ b/include/media/dvb-usb-ids.h @@ -0,0 +1,424 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* dvb-usb-ids.h is part of the DVB USB library. + * + * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de) see + * dvb-usb-init.c for copyright information. + * + * a header file containing define's for the USB device supported by the + * various drivers. + */ +#ifndef _DVB_USB_IDS_H_ +#define _DVB_USB_IDS_H_ + +/* Vendor IDs */ +#define USB_VID_ADSTECH 0x06e1 +#define USB_VID_AFATECH 0x15a4 +#define USB_VID_ALCOR_MICRO 0x058f +#define USB_VID_ALINK 0x05e3 +#define USB_VID_AMT 0x1c73 +#define USB_VID_ANCHOR 0x0547 +#define USB_VID_ANSONIC 0x10b9 +#define USB_VID_ANUBIS_ELECTRONIC 0x10fd +#define USB_VID_ASUS 0x0b05 +#define USB_VID_AVERMEDIA 0x07ca +#define USB_VID_COMPRO 0x185b +#define USB_VID_COMPRO_UNK 0x145f +#define USB_VID_CONEXANT 0x0572 +#define USB_VID_CYPRESS 0x04b4 +#define USB_VID_DEXATEK 0x1d19 +#define USB_VID_DIBCOM 0x10b8 +#define USB_VID_DPOSH 0x1498 +#define USB_VID_DVICO 0x0fe9 +#define USB_VID_E3C 0x18b4 +#define USB_VID_ELGATO 0x0fd9 +#define USB_VID_EMPIA 0xeb1a +#define USB_VID_GENPIX 0x09c0 +#define USB_VID_GRANDTEC 0x5032 +#define USB_VID_GTEK 0x1f4d +#define USB_VID_HANFTEK 0x15f4 +#define USB_VID_HAUPPAUGE 0x2040 +#define USB_VID_HYPER_PALTEK 0x1025 +#define USB_VID_INTEL 0x8086 +#define USB_VID_ITETECH 0x048d +#define USB_VID_KWORLD 0xeb2a +#define USB_VID_KWORLD_2 0x1b80 +#define USB_VID_KYE 0x0458 +#define USB_VID_LEADTEK 0x0413 +#define USB_VID_LITEON 0x04ca +#define USB_VID_MEDION 0x1660 +#define USB_VID_MIGLIA 0x18f3 +#define USB_VID_MSI 0x0db0 +#define USB_VID_MSI_2 0x1462 +#define USB_VID_OPERA1 0x695c +#define USB_VID_PINNACLE 0x2304 +#define USB_VID_PCTV 0x2013 +#define USB_VID_PIXELVIEW 0x1554 +#define USB_VID_REALTEK 0x0bda +#define USB_VID_TECHNOTREND 0x0b48 +#define USB_VID_TERRATEC 0x0ccd +#define USB_VID_TELESTAR 0x10b9 +#define USB_VID_VISIONPLUS 0x13d3 +#define USB_VID_SONY 0x1415 +#define USB_PID_TEVII_S421 0xd421 +#define USB_PID_TEVII_S480_1 0xd481 +#define USB_PID_TEVII_S480_2 0xd482 +#define USB_PID_TEVII_S630 0xd630 +#define USB_PID_TEVII_S632 0xd632 +#define USB_PID_TEVII_S650 0xd650 +#define USB_PID_TEVII_S660 0xd660 +#define USB_PID_TEVII_S662 0xd662 +#define USB_VID_TWINHAN 0x1822 +#define USB_VID_ULTIMA_ELECTRONIC 0x05d8 +#define USB_VID_UNIWILL 0x1584 +#define USB_VID_WIDEVIEW 0x14aa +#define USB_VID_GIGABYTE 0x1044 +#define USB_VID_YUAN 0x1164 +#define USB_VID_XTENSIONS 0x1ae7 +#define USB_VID_ZYDAS 0x0ace +#define USB_VID_HUMAX_COEX 0x10b9 +#define USB_VID_774 0x7a69 +#define USB_VID_EVOLUTEPC 0x1e59 +#define USB_VID_AZUREWAVE 0x13d3 +#define USB_VID_TECHNISAT 0x14f7 +#define USB_VID_HAMA 0x147f +#define USB_VID_MICROSOFT 0x045e + +/* Product IDs */ +#define USB_PID_ADSTECH_USB2_COLD 0xa333 +#define USB_PID_ADSTECH_USB2_WARM 0xa334 +#define USB_PID_AFATECH_AF9005 0x9020 +#define USB_PID_AFATECH_AF9015_9015 0x9015 +#define USB_PID_AFATECH_AF9015_9016 0x9016 +#define USB_PID_AFATECH_AF9035_1000 0x1000 +#define USB_PID_AFATECH_AF9035_1001 0x1001 +#define USB_PID_AFATECH_AF9035_1002 0x1002 +#define USB_PID_AFATECH_AF9035_1003 0x1003 +#define USB_PID_AFATECH_AF9035_9035 0x9035 +#define USB_PID_TREKSTOR_DVBT 0x901b +#define USB_PID_TREKSTOR_TERRES_2_0 0xC803 +#define USB_VID_ALINK_DTU 0xf170 +#define USB_PID_ANSONIC_DVBT_USB 0x6000 +#define USB_PID_ANYSEE 0x861f +#define USB_PID_AZUREWAVE_AD_TU700 0x3237 +#define USB_PID_AZUREWAVE_6007 0x0ccd +#define USB_PID_AVERMEDIA_DVBT_USB_COLD 0x0001 +#define USB_PID_AVERMEDIA_DVBT_USB_WARM 0x0002 +#define USB_PID_AVERMEDIA_DVBT_USB2_COLD 0xa800 +#define USB_PID_AVERMEDIA_DVBT_USB2_WARM 0xa801 +#define USB_PID_COMPRO_DVBU2000_COLD 0xd000 +#define USB_PID_COMPRO_DVBU2000_WARM 0xd001 +#define USB_PID_COMPRO_DVBU2000_UNK_COLD 0x010c +#define USB_PID_COMPRO_DVBU2000_UNK_WARM 0x010d +#define USB_PID_COMPRO_VIDEOMATE_U500 0x1e78 +#define USB_PID_COMPRO_VIDEOMATE_U500_PC 0x1e80 +#define USB_PID_CONCEPTRONIC_CTVDIGRCU 0xe397 +#define USB_PID_CONEXANT_D680_DMB 0x86d6 +#define USB_PID_CREATIX_CTX1921 0x1921 +#define USB_PID_DELOCK_USB2_DVBT 0xb803 +#define USB_PID_DIBCOM_HOOK_DEFAULT 0x0064 +#define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065 +#define USB_PID_DIBCOM_MOD3000_COLD 0x0bb8 +#define USB_PID_DIBCOM_MOD3000_WARM 0x0bb9 +#define USB_PID_DIBCOM_MOD3001_COLD 0x0bc6 +#define USB_PID_DIBCOM_MOD3001_WARM 0x0bc7 +#define USB_PID_DIBCOM_STK7700P 0x1e14 +#define USB_PID_DIBCOM_STK7700P_PC 0x1e78 +#define USB_PID_DIBCOM_STK7700D 0x1ef0 +#define USB_PID_DIBCOM_STK7700_U7000 0x7001 +#define USB_PID_DIBCOM_STK7070P 0x1ebc +#define USB_PID_DIBCOM_STK7070PD 0x1ebe +#define USB_PID_DIBCOM_STK807XP 0x1f90 +#define USB_PID_DIBCOM_STK807XPVR 0x1f98 +#define USB_PID_DIBCOM_STK8096GP 0x1fa0 +#define USB_PID_DIBCOM_STK8096PVR 0x1faa +#define USB_PID_DIBCOM_NIM8096MD 0x1fa8 +#define USB_PID_DIBCOM_TFE8096P 0x1f9C +#define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131 +#define USB_PID_DIBCOM_STK7770P 0x1e80 +#define USB_PID_DIBCOM_NIM7090 0x1bb2 +#define USB_PID_DIBCOM_TFE7090PVR 0x1bb4 +#define USB_PID_DIBCOM_TFE7790P 0x1e6e +#define USB_PID_DIBCOM_NIM9090M 0x2383 +#define USB_PID_DIBCOM_NIM9090MD 0x2384 +#define USB_PID_DPOSH_M9206_COLD 0x9206 +#define USB_PID_DPOSH_M9206_WARM 0xa090 +#define USB_PID_E3C_EC168 0x1689 +#define USB_PID_E3C_EC168_2 0xfffa +#define USB_PID_E3C_EC168_3 0xfffb +#define USB_PID_E3C_EC168_4 0x1001 +#define USB_PID_E3C_EC168_5 0x1002 +#define USB_PID_FREECOM_DVBT 0x0160 +#define USB_PID_FREECOM_DVBT_2 0x0161 +#define USB_PID_UNIWILL_STK7700P 0x6003 +#define USB_PID_GENIUS_TVGO_DVB_T03 0x4012 +#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 +#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 +#define USB_PID_GOTVIEW_SAT_HD 0x5456 +#define USB_PID_INTEL_CE9500 0x9500 +#define USB_PID_ITETECH_IT9135 0x9135 +#define USB_PID_ITETECH_IT9135_9005 0x9005 +#define USB_PID_ITETECH_IT9135_9006 0x9006 +#define USB_PID_ITETECH_IT9303 0x9306 +#define USB_PID_KWORLD_399U 0xe399 +#define USB_PID_KWORLD_399U_2 0xe400 +#define USB_PID_KWORLD_395U 0xe396 +#define USB_PID_KWORLD_395U_2 0xe39b +#define USB_PID_KWORLD_395U_3 0xe395 +#define USB_PID_KWORLD_395U_4 0xe39a +#define USB_PID_KWORLD_MC810 0xc810 +#define USB_PID_KWORLD_PC160_2T 0xc160 +#define USB_PID_KWORLD_PC160_T 0xc161 +#define USB_PID_KWORLD_UB383_T 0xe383 +#define USB_PID_KWORLD_UB499_2T_T09 0xe409 +#define USB_PID_KWORLD_VSTREAM_COLD 0x17de +#define USB_PID_KWORLD_VSTREAM_WARM 0x17df +#define USB_PID_PROF_1100 0xb012 +#define USB_PID_TERRATEC_CINERGY_S 0x0064 +#define USB_PID_TERRATEC_CINERGY_T_USB_XE 0x0055 +#define USB_PID_TERRATEC_CINERGY_T_USB_XE_REV2 0x0069 +#define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093 +#define USB_PID_TERRATEC_CINERGY_T_STICK_RC 0x0097 +#define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099 +#define USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1 0x00a9 +#define USB_PID_TWINHAN_VP7041_COLD 0x3201 +#define USB_PID_TWINHAN_VP7041_WARM 0x3202 +#define USB_PID_TWINHAN_VP7020_COLD 0x3203 +#define USB_PID_TWINHAN_VP7020_WARM 0x3204 +#define USB_PID_TWINHAN_VP7045_COLD 0x3205 +#define USB_PID_TWINHAN_VP7045_WARM 0x3206 +#define USB_PID_TWINHAN_VP7021_COLD 0x3207 +#define USB_PID_TWINHAN_VP7021_WARM 0x3208 +#define USB_PID_TWINHAN_VP7049 0x3219 +#define USB_PID_TINYTWIN 0x3226 +#define USB_PID_TINYTWIN_2 0xe402 +#define USB_PID_TINYTWIN_3 0x9016 +#define USB_PID_DNTV_TINYUSB2_COLD 0x3223 +#define USB_PID_DNTV_TINYUSB2_WARM 0x3224 +#define USB_PID_ULTIMA_TVBOX_COLD 0x8105 +#define USB_PID_ULTIMA_TVBOX_WARM 0x8106 +#define USB_PID_ULTIMA_TVBOX_AN2235_COLD 0x8107 +#define USB_PID_ULTIMA_TVBOX_AN2235_WARM 0x8108 +#define USB_PID_ULTIMA_TVBOX_ANCHOR_COLD 0x2235 +#define USB_PID_ULTIMA_TVBOX_USB2_COLD 0x8109 +#define USB_PID_ULTIMA_TVBOX_USB2_WARM 0x810a +#define USB_PID_ARTEC_T14_COLD 0x810b +#define USB_PID_ARTEC_T14_WARM 0x810c +#define USB_PID_ARTEC_T14BR 0x810f +#define USB_PID_ULTIMA_TVBOX_USB2_FX_COLD 0x8613 +#define USB_PID_ULTIMA_TVBOX_USB2_FX_WARM 0x1002 +#define USB_PID_UNK_HYPER_PALTEK_COLD 0x005e +#define USB_PID_UNK_HYPER_PALTEK_WARM 0x005f +#define USB_PID_HANFTEK_UMT_010_COLD 0x0001 +#define USB_PID_HANFTEK_UMT_010_WARM 0x0015 +#define USB_PID_DTT200U_COLD 0x0201 +#define USB_PID_DTT200U_WARM 0x0301 +#define USB_PID_WT220U_ZAP250_COLD 0x0220 +#define USB_PID_WT220U_COLD 0x0222 +#define USB_PID_WT220U_WARM 0x0221 +#define USB_PID_WT220U_FC_COLD 0x0225 +#define USB_PID_WT220U_FC_WARM 0x0226 +#define USB_PID_WT220U_ZL0353_COLD 0x022a +#define USB_PID_WT220U_ZL0353_WARM 0x022b +#define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300 +#define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301 +#define USB_PID_HAUPPAUGE_NOVA_T_500 0x9941 +#define USB_PID_HAUPPAUGE_NOVA_T_500_2 0x9950 +#define USB_PID_HAUPPAUGE_NOVA_T_500_3 0x8400 +#define USB_PID_HAUPPAUGE_NOVA_T_STICK 0x7050 +#define USB_PID_HAUPPAUGE_NOVA_T_STICK_2 0x7060 +#define USB_PID_HAUPPAUGE_NOVA_T_STICK_3 0x7070 +#define USB_PID_HAUPPAUGE_MYTV_T 0x7080 +#define USB_PID_HAUPPAUGE_NOVA_TD_STICK 0x9580 +#define USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009 0x5200 +#define USB_PID_HAUPPAUGE_TIGER_ATSC 0xb200 +#define USB_PID_HAUPPAUGE_TIGER_ATSC_B210 0xb210 +#define USB_PID_AVERMEDIA_EXPRESS 0xb568 +#define USB_PID_AVERMEDIA_VOLAR 0xa807 +#define USB_PID_AVERMEDIA_VOLAR_2 0xb808 +#define USB_PID_AVERMEDIA_VOLAR_A868R 0xa868 +#define USB_PID_AVERMEDIA_MCE_USB_M038 0x1228 +#define USB_PID_AVERMEDIA_HYBRID_ULTRA_USB_M039R 0x0039 +#define USB_PID_AVERMEDIA_HYBRID_ULTRA_USB_M039R_ATSC 0x1039 +#define USB_PID_AVERMEDIA_HYBRID_ULTRA_USB_M039R_DVBT 0x2039 +#define USB_PID_AVERMEDIA_VOLAR_X 0xa815 +#define USB_PID_AVERMEDIA_VOLAR_X_2 0x8150 +#define USB_PID_AVERMEDIA_A309 0xa309 +#define USB_PID_AVERMEDIA_A310 0xa310 +#define USB_PID_AVERMEDIA_A850 0x850a +#define USB_PID_AVERMEDIA_A850T 0x850b +#define USB_PID_AVERMEDIA_A805 0xa805 +#define USB_PID_AVERMEDIA_A815M 0x815a +#define USB_PID_AVERMEDIA_A835 0xa835 +#define USB_PID_AVERMEDIA_B835 0xb835 +#define USB_PID_AVERMEDIA_A835B_1835 0x1835 +#define USB_PID_AVERMEDIA_A835B_2835 0x2835 +#define USB_PID_AVERMEDIA_A835B_3835 0x3835 +#define USB_PID_AVERMEDIA_A835B_4835 0x4835 +#define USB_PID_AVERMEDIA_1867 0x1867 +#define USB_PID_AVERMEDIA_A867 0xa867 +#define USB_PID_AVERMEDIA_H335 0x0335 +#define USB_PID_AVERMEDIA_TD110 0xa110 +#define USB_PID_AVERMEDIA_TWINSTAR 0x0825 +#define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006 +#define USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM 0x3009 +#define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d +#define USB_PID_TECHNOTREND_CONNECT_S2_4600 0x3011 +#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI 0x3012 +#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2 0x3015 +#define USB_PID_TECHNOTREND_TVSTICK_CT2_4400 0x3014 +#define USB_PID_TECHNOTREND_CONNECT_S2_4650_CI 0x3017 +#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a +#define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081 +#define USB_PID_TERRATEC_CINERGY_HT_USB_XE 0x0058 +#define USB_PID_TERRATEC_CINERGY_HT_EXPRESS 0x0060 +#define USB_PID_TERRATEC_CINERGY_T_EXPRESS 0x0062 +#define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078 +#define USB_PID_TERRATEC_CINERGY_T_XXS_2 0x00ab +#define USB_PID_TERRATEC_CINERGY_S2_R1 0x00a8 +#define USB_PID_TERRATEC_CINERGY_S2_R2 0x00b0 +#define USB_PID_TERRATEC_CINERGY_S2_R3 0x0102 +#define USB_PID_TERRATEC_CINERGY_S2_R4 0x0105 +#define USB_PID_TERRATEC_H7 0x10b4 +#define USB_PID_TERRATEC_H7_2 0x10a3 +#define USB_PID_TERRATEC_H7_3 0x10a5 +#define USB_PID_TERRATEC_T1 0x10ae +#define USB_PID_TERRATEC_T3 0x10a0 +#define USB_PID_TERRATEC_T5 0x10a1 +#define USB_PID_NOXON_DAB_STICK 0x00b3 +#define USB_PID_NOXON_DAB_STICK_REV2 0x00e0 +#define USB_PID_NOXON_DAB_STICK_REV3 0x00b4 +#define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e +#define USB_PID_PINNACLE_PCTV2000E 0x022c +#define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 +#define USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T 0x0229 +#define USB_PID_PINNACLE_PCTV71E 0x022b +#define USB_PID_PINNACLE_PCTV72E 0x0236 +#define USB_PID_PINNACLE_PCTV73E 0x0237 +#define USB_PID_PINNACLE_PCTV310E 0x3211 +#define USB_PID_PINNACLE_PCTV801E 0x023a +#define USB_PID_PINNACLE_PCTV801E_SE 0x023b +#define USB_PID_PINNACLE_PCTV340E 0x023d +#define USB_PID_PINNACLE_PCTV340E_SE 0x023e +#define USB_PID_PINNACLE_PCTV73A 0x0243 +#define USB_PID_PINNACLE_PCTV73ESE 0x0245 +#define USB_PID_PINNACLE_PCTV74E 0x0246 +#define USB_PID_PINNACLE_PCTV282E 0x0248 +#define USB_PID_PIXELVIEW_SBTVD 0x5010 +#define USB_PID_PCTV_200E 0x020e +#define USB_PID_PCTV_400E 0x020f +#define USB_PID_PCTV_450E 0x0222 +#define USB_PID_PCTV_452E 0x021f +#define USB_PID_PCTV_78E 0x025a +#define USB_PID_PCTV_79E 0x0262 +#define USB_PID_REALTEK_RTL2831U 0x2831 +#define USB_PID_REALTEK_RTL2832U 0x2832 +#define USB_PID_TECHNOTREND_CONNECT_S2_3600 0x3007 +#define USB_PID_TECHNOTREND_CONNECT_S2_3650_CI 0x300a +#define USB_PID_NEBULA_DIGITV 0x0201 +#define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820 +#define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500 +#define USB_PID_DVICO_BLUEBIRD_LG064F_WARM 0xd501 +#define USB_PID_DVICO_BLUEBIRD_LGZ201_COLD 0xdb00 +#define USB_PID_DVICO_BLUEBIRD_LGZ201_WARM 0xdb01 +#define USB_PID_DVICO_BLUEBIRD_TH7579_COLD 0xdb10 +#define USB_PID_DVICO_BLUEBIRD_TH7579_WARM 0xdb11 +#define USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD 0xdb50 +#define USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM 0xdb51 +#define USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD 0xdb58 +#define USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM 0xdb59 +#define USB_PID_DVICO_BLUEBIRD_DUAL_4 0xdb78 +#define USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2 0xdb98 +#define USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2 0xdb70 +#define USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM 0xdb71 +#define USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD 0xdb54 +#define USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM 0xdb55 +#define USB_PID_MEDION_MD95700 0x0932 +#define USB_PID_MSI_MEGASKY580 0x5580 +#define USB_PID_MSI_MEGASKY580_55801 0x5581 +#define USB_PID_KYE_DVB_T_COLD 0x701e +#define USB_PID_KYE_DVB_T_WARM 0x701f +#define USB_PID_LITEON_DVB_T_COLD 0xf000 +#define USB_PID_LITEON_DVB_T_WARM 0xf001 +#define USB_PID_DIGIVOX_MINI_SL_COLD 0xe360 +#define USB_PID_DIGIVOX_MINI_SL_WARM 0xe361 +#define USB_PID_GRANDTEC_DVBT_USB2_COLD 0x0bc6 +#define USB_PID_GRANDTEC_DVBT_USB2_WARM 0x0bc7 +#define USB_PID_WINFAST_DTV2000DS 0x6a04 +#define USB_PID_WINFAST_DTV2000DS_PLUS 0x6f12 +#define USB_PID_WINFAST_DTV_DONGLE_COLD 0x6025 +#define USB_PID_WINFAST_DTV_DONGLE_WARM 0x6026 +#define USB_PID_WINFAST_DTV_DONGLE_STK7700P 0x6f00 +#define USB_PID_WINFAST_DTV_DONGLE_H 0x60f6 +#define USB_PID_WINFAST_DTV_DONGLE_STK7700P_2 0x6f01 +#define USB_PID_WINFAST_DTV_DONGLE_GOLD 0x6029 +#define USB_PID_WINFAST_DTV_DONGLE_MINID 0x6f0f +#define USB_PID_GENPIX_8PSK_REV_1_COLD 0x0200 +#define USB_PID_GENPIX_8PSK_REV_1_WARM 0x0201 +#define USB_PID_GENPIX_8PSK_REV_2 0x0202 +#define USB_PID_GENPIX_SKYWALKER_1 0x0203 +#define USB_PID_GENPIX_SKYWALKER_CW3K 0x0204 +#define USB_PID_GENPIX_SKYWALKER_2 0x0206 +#define USB_PID_SIGMATEK_DVB_110 0x6610 +#define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513 +#define USB_PID_MSI_DIGIVOX_DUO 0x8801 +#define USB_PID_OPERA1_COLD 0x2830 +#define USB_PID_OPERA1_WARM 0x3829 +#define USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD 0x0514 +#define USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM 0x0513 +#define USB_PID_GIGABYTE_U7000 0x7001 +#define USB_PID_GIGABYTE_U8000 0x7002 +#define USB_PID_ASUS_U3000 0x171f +#define USB_PID_ASUS_U3000H 0x1736 +#define USB_PID_ASUS_U3100 0x173f +#define USB_PID_ASUS_U3100MINI_PLUS 0x1779 +#define USB_PID_YUAN_EC372S 0x1edc +#define USB_PID_YUAN_STK7700PH 0x1f08 +#define USB_PID_YUAN_PD378S 0x2edc +#define USB_PID_YUAN_MC770 0x0871 +#define USB_PID_YUAN_STK7700D 0x1efc +#define USB_PID_YUAN_STK7700D_2 0x1e8c +#define USB_PID_DW2102 0x2102 +#define USB_PID_DW2104 0x2104 +#define USB_PID_DW3101 0x3101 +#define USB_PID_XTENSIONS_XD_380 0x0381 +#define USB_PID_TELESTAR_STARSTICK_2 0x8000 +#define USB_PID_MSI_DIGI_VOX_MINI_III 0x8807 +#define USB_PID_SONY_PLAYTV 0x0003 +#define USB_PID_MYGICA_D689 0xd811 +#define USB_PID_MYGICA_T230 0xc688 +#define USB_PID_MYGICA_T230C 0xc689 +#define USB_PID_ELGATO_EYETV_DIVERSITY 0x0011 +#define USB_PID_ELGATO_EYETV_DTT 0x0021 +#define USB_PID_ELGATO_EYETV_DTT_2 0x003f +#define USB_PID_ELGATO_EYETV_DTT_Dlx 0x0020 +#define USB_PID_ELGATO_EYETV_SAT 0x002a +#define USB_PID_ELGATO_EYETV_SAT_V2 0x0025 +#define USB_PID_ELGATO_EYETV_SAT_V3 0x0036 +#define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD 0x5000 +#define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_WARM 0x5001 +#define USB_PID_FRIIO_WHITE 0x0001 +#define USB_PID_TVWAY_PLUS 0x0002 +#define USB_PID_SVEON_STV20 0xe39d +#define USB_PID_SVEON_STV20_RTL2832U 0xd39d +#define USB_PID_SVEON_STV21 0xd3b0 +#define USB_PID_SVEON_STV22 0xe401 +#define USB_PID_SVEON_STV22_IT9137 0xe411 +#define USB_PID_AZUREWAVE_AZ6027 0x3275 +#define USB_PID_TERRATEC_DVBS2CI_V1 0x10a4 +#define USB_PID_TERRATEC_DVBS2CI_V2 0x10ac +#define USB_PID_TECHNISAT_USB2_HDCI_V1 0x0001 +#define USB_PID_TECHNISAT_USB2_HDCI_V2 0x0002 +#define USB_PID_TECHNISAT_USB2_CABLESTAR_HDCI 0x0003 +#define USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2 0x0004 +#define USB_PID_TECHNISAT_USB2_DVB_S2 0x0500 +#define USB_PID_CPYTO_REDI_PC50A 0xa803 +#define USB_PID_CTVDIGDUAL_V2 0xe410 +#define USB_PID_PCTV_2002E 0x025c +#define USB_PID_PCTV_2002E_SE 0x025d +#define USB_PID_SVEON_STV27 0xd3af +#define USB_PID_TURBOX_DTT_2000 0xd3a4 +#define USB_PID_WINTV_SOLOHD 0x0264 +#define USB_PID_EVOLVEO_XTRATV_STICK 0xa115 +#define USB_PID_HAMA_DVBT_HYBRID 0x2758 +#define USB_PID_XBOX_ONE_TUNER 0x02d5 +#endif diff --git a/include/media/dvb_ca_en50221.h b/include/media/dvb_ca_en50221.h new file mode 100644 index 000000000000..a1c014b0a837 --- /dev/null +++ b/include/media/dvb_ca_en50221.h @@ -0,0 +1,142 @@ +/* + * dvb_ca.h: generic DVB functions for EN50221 CA interfaces + * + * Copyright (C) 2004 Andrew de Quincey + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef _DVB_CA_EN50221_H_ +#define _DVB_CA_EN50221_H_ + +#include +#include + +#include + +#define DVB_CA_EN50221_POLL_CAM_PRESENT 1 +#define DVB_CA_EN50221_POLL_CAM_CHANGED 2 +#define DVB_CA_EN50221_POLL_CAM_READY 4 + +#define DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE 1 +#define DVB_CA_EN50221_FLAG_IRQ_FR 2 +#define DVB_CA_EN50221_FLAG_IRQ_DA 4 + +#define DVB_CA_EN50221_CAMCHANGE_REMOVED 0 +#define DVB_CA_EN50221_CAMCHANGE_INSERTED 1 + +/** + * struct dvb_ca_en50221- Structure describing a CA interface + * + * @owner: the module owning this structure + * @read_attribute_mem: function for reading attribute memory on the CAM + * @write_attribute_mem: function for writing attribute memory on the CAM + * @read_cam_control: function for reading the control interface on the CAM + * @write_cam_control: function for reading the control interface on the CAM + * @read_data: function for reading data (block mode) + * @write_data: function for writing data (block mode) + * @slot_reset: function to reset the CAM slot + * @slot_shutdown: function to shutdown a CAM slot + * @slot_ts_enable: function to enable the Transport Stream on a CAM slot + * @poll_slot_status: function to poll slot status. Only necessary if + * DVB_CA_FLAG_EN50221_IRQ_CAMCHANGE is not set. + * @data: private data, used by caller. + * @private: Opaque data used by the dvb_ca core. Do not modify! + * + * NOTE: the read_*, write_* and poll_slot_status functions will be + * called for different slots concurrently and need to use locks where + * and if appropriate. There will be no concurrent access to one slot. + */ +struct dvb_ca_en50221 { + struct module *owner; + + int (*read_attribute_mem)(struct dvb_ca_en50221 *ca, + int slot, int address); + int (*write_attribute_mem)(struct dvb_ca_en50221 *ca, + int slot, int address, u8 value); + + int (*read_cam_control)(struct dvb_ca_en50221 *ca, + int slot, u8 address); + int (*write_cam_control)(struct dvb_ca_en50221 *ca, + int slot, u8 address, u8 value); + + int (*read_data)(struct dvb_ca_en50221 *ca, + int slot, u8 *ebuf, int ecount); + int (*write_data)(struct dvb_ca_en50221 *ca, + int slot, u8 *ebuf, int ecount); + + int (*slot_reset)(struct dvb_ca_en50221 *ca, int slot); + int (*slot_shutdown)(struct dvb_ca_en50221 *ca, int slot); + int (*slot_ts_enable)(struct dvb_ca_en50221 *ca, int slot); + + int (*poll_slot_status)(struct dvb_ca_en50221 *ca, int slot, int open); + + void *data; + + void *private; +}; + +/* + * Functions for reporting IRQ events + */ + +/** + * dvb_ca_en50221_camchange_irq - A CAMCHANGE IRQ has occurred. + * + * @pubca: CA instance. + * @slot: Slot concerned. + * @change_type: One of the DVB_CA_CAMCHANGE_* values + */ +void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot, + int change_type); + +/** + * dvb_ca_en50221_camready_irq - A CAMREADY IRQ has occurred. + * + * @pubca: CA instance. + * @slot: Slot concerned. + */ +void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot); + +/** + * dvb_ca_en50221_frda_irq - An FR or a DA IRQ has occurred. + * + * @ca: CA instance. + * @slot: Slot concerned. + */ +void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *ca, int slot); + +/* + * Initialisation/shutdown functions + */ + +/** + * dvb_ca_en50221_init - Initialise a new DVB CA device. + * + * @dvb_adapter: DVB adapter to attach the new CA device to. + * @ca: The dvb_ca instance. + * @flags: Flags describing the CA device (DVB_CA_EN50221_FLAG_*). + * @slot_count: Number of slots supported. + * + * @return 0 on success, nonzero on failure + */ +int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, + struct dvb_ca_en50221 *ca, int flags, + int slot_count); + +/** + * dvb_ca_en50221_release - Release a DVB CA device. + * + * @ca: The associated dvb_ca instance. + */ +void dvb_ca_en50221_release(struct dvb_ca_en50221 *ca); + +#endif diff --git a/include/media/dvb_demux.h b/include/media/dvb_demux.h new file mode 100644 index 000000000000..b07092038f4b --- /dev/null +++ b/include/media/dvb_demux.h @@ -0,0 +1,350 @@ +/* + * dvb_demux.h: DVB kernel demux API + * + * Copyright (C) 2000-2001 Marcus Metzler & Ralph Metzler + * for convergence integrated media GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _DVB_DEMUX_H_ +#define _DVB_DEMUX_H_ + +#include +#include +#include +#include + +#include + +/** + * enum dvb_dmx_filter_type - type of demux feed. + * + * @DMX_TYPE_TS: feed is in TS mode. + * @DMX_TYPE_SEC: feed is in Section mode. + */ +enum dvb_dmx_filter_type { + DMX_TYPE_TS, + DMX_TYPE_SEC, +}; + +/** + * enum dvb_dmx_state - state machine for a demux filter. + * + * @DMX_STATE_FREE: indicates that the filter is freed. + * @DMX_STATE_ALLOCATED: indicates that the filter was allocated + * to be used. + * @DMX_STATE_READY: indicates that the filter is ready + * to be used. + * @DMX_STATE_GO: indicates that the filter is running. + */ +enum dvb_dmx_state { + DMX_STATE_FREE, + DMX_STATE_ALLOCATED, + DMX_STATE_READY, + DMX_STATE_GO, +}; + +#define DVB_DEMUX_MASK_MAX 18 + +#define MAX_PID 0x1fff + +#define SPEED_PKTS_INTERVAL 50000 + +/** + * struct dvb_demux_filter - Describes a DVB demux section filter. + * + * @filter: Section filter as defined by &struct dmx_section_filter. + * @maskandmode: logical ``and`` bit mask. + * @maskandnotmode: logical ``and not`` bit mask. + * @doneq: flag that indicates when a filter is ready. + * @next: pointer to the next section filter. + * @feed: &struct dvb_demux_feed pointer. + * @index: index of the used demux filter. + * @state: state of the filter as described by &enum dvb_dmx_state. + * @type: type of the filter as described + * by &enum dvb_dmx_filter_type. + */ + +struct dvb_demux_filter { + struct dmx_section_filter filter; + u8 maskandmode[DMX_MAX_FILTER_SIZE]; + u8 maskandnotmode[DMX_MAX_FILTER_SIZE]; + bool doneq; + + struct dvb_demux_filter *next; + struct dvb_demux_feed *feed; + int index; + enum dvb_dmx_state state; + enum dvb_dmx_filter_type type; + + /* private: used only by av7110 */ + u16 hw_handle; +}; + +/** + * struct dvb_demux_feed - describes a DVB field + * + * @feed: a union describing a digital TV feed. + * Depending on the feed type, it can be either + * @feed.ts or @feed.sec. + * @feed.ts: a &struct dmx_ts_feed pointer. + * For TS feed only. + * @feed.sec: a &struct dmx_section_feed pointer. + * For section feed only. + * @cb: a union describing digital TV callbacks. + * Depending on the feed type, it can be either + * @cb.ts or @cb.sec. + * @cb.ts: a dmx_ts_cb() calback function pointer. + * For TS feed only. + * @cb.sec: a dmx_section_cb() callback function pointer. + * For section feed only. + * @demux: pointer to &struct dvb_demux. + * @priv: private data that can optionally be used by a DVB driver. + * @type: type of the filter, as defined by &enum dvb_dmx_filter_type. + * @state: state of the filter as defined by &enum dvb_dmx_state. + * @pid: PID to be filtered. + * @timeout: feed timeout. + * @filter: pointer to &struct dvb_demux_filter. + * @ts_type: type of TS, as defined by &enum ts_filter_type. + * @pes_type: type of PES, as defined by &enum dmx_ts_pes. + * @cc: MPEG-TS packet continuity counter + * @pusi_seen: if true, indicates that a discontinuity was detected. + * it is used to prevent feeding of garbage from previous section. + * @peslen: length of the PES (Packet Elementary Stream). + * @list_head: head for the list of digital TV demux feeds. + * @index: a unique index for each feed. Can be used as hardware + * pid filter index. + */ +struct dvb_demux_feed { + union { + struct dmx_ts_feed ts; + struct dmx_section_feed sec; + } feed; + + union { + dmx_ts_cb ts; + dmx_section_cb sec; + } cb; + + struct dvb_demux *demux; + void *priv; + enum dvb_dmx_filter_type type; + enum dvb_dmx_state state; + u16 pid; + + ktime_t timeout; + struct dvb_demux_filter *filter; + + enum ts_filter_type ts_type; + enum dmx_ts_pes pes_type; + + int cc; + bool pusi_seen; + + u16 peslen; + + struct list_head list_head; + unsigned int index; +}; + +/** + * struct dvb_demux - represents a digital TV demux + * @dmx: embedded &struct dmx_demux with demux capabilities + * and callbacks. + * @priv: private data that can optionally be used by + * a DVB driver. + * @filternum: maximum amount of DVB filters. + * @feednum: maximum amount of DVB feeds. + * @start_feed: callback routine to be called in order to start + * a DVB feed. + * @stop_feed: callback routine to be called in order to stop + * a DVB feed. + * @write_to_decoder: callback routine to be called if the feed is TS and + * it is routed to an A/V decoder, when a new TS packet + * is received. + * Used only on av7110-av.c. + * @check_crc32: callback routine to check CRC. If not initialized, + * dvb_demux will use an internal one. + * @memcopy: callback routine to memcopy received data. + * If not initialized, dvb_demux will default to memcpy(). + * @users: counter for the number of demux opened file descriptors. + * Currently, it is limited to 10 users. + * @filter: pointer to &struct dvb_demux_filter. + * @feed: pointer to &struct dvb_demux_feed. + * @frontend_list: &struct list_head with frontends used by the demux. + * @pesfilter: array of &struct dvb_demux_feed with the PES types + * that will be filtered. + * @pids: list of filtered program IDs. + * @feed_list: &struct list_head with feeds. + * @tsbuf: temporary buffer used internally to store TS packets. + * @tsbufp: temporary buffer index used internally. + * @mutex: pointer to &struct mutex used to protect feed set + * logic. + * @lock: pointer to &spinlock_t, used to protect buffer handling. + * @cnt_storage: buffer used for TS/TEI continuity check. + * @speed_last_time: &ktime_t used for TS speed check. + * @speed_pkts_cnt: packets count used for TS speed check. + */ +struct dvb_demux { + struct dmx_demux dmx; + void *priv; + int filternum; + int feednum; + int (*start_feed)(struct dvb_demux_feed *feed); + int (*stop_feed)(struct dvb_demux_feed *feed); + int (*write_to_decoder)(struct dvb_demux_feed *feed, + const u8 *buf, size_t len); + u32 (*check_crc32)(struct dvb_demux_feed *feed, + const u8 *buf, size_t len); + void (*memcopy)(struct dvb_demux_feed *feed, u8 *dst, + const u8 *src, size_t len); + + int users; +#define MAX_DVB_DEMUX_USERS 10 + struct dvb_demux_filter *filter; + struct dvb_demux_feed *feed; + + struct list_head frontend_list; + + struct dvb_demux_feed *pesfilter[DMX_PES_OTHER]; + u16 pids[DMX_PES_OTHER]; + +#define DMX_MAX_PID 0x2000 + struct list_head feed_list; + u8 tsbuf[204]; + int tsbufp; + + struct mutex mutex; + spinlock_t lock; + + uint8_t *cnt_storage; /* for TS continuity check */ + + ktime_t speed_last_time; /* for TS speed check */ + uint32_t speed_pkts_cnt; /* for TS speed check */ + + /* private: used only on av7110 */ + int playing; + int recording; +}; + +/** + * dvb_dmx_init - initialize a digital TV demux struct. + * + * @demux: &struct dvb_demux to be initialized. + * + * Before being able to register a digital TV demux struct, drivers + * should call this routine. On its typical usage, some fields should + * be initialized at the driver before calling it. + * + * A typical usecase is:: + * + * dvb->demux.dmx.capabilities = + * DMX_TS_FILTERING | DMX_SECTION_FILTERING | + * DMX_MEMORY_BASED_FILTERING; + * dvb->demux.priv = dvb; + * dvb->demux.filternum = 256; + * dvb->demux.feednum = 256; + * dvb->demux.start_feed = driver_start_feed; + * dvb->demux.stop_feed = driver_stop_feed; + * ret = dvb_dmx_init(&dvb->demux); + * if (ret < 0) + * return ret; + */ +int dvb_dmx_init(struct dvb_demux *demux); + +/** + * dvb_dmx_release - releases a digital TV demux internal buffers. + * + * @demux: &struct dvb_demux to be released. + * + * The DVB core internally allocates data at @demux. This routine + * releases those data. Please notice that the struct itelf is not + * released, as it can be embedded on other structs. + */ +void dvb_dmx_release(struct dvb_demux *demux); + +/** + * dvb_dmx_swfilter_packets - use dvb software filter for a buffer with + * multiple MPEG-TS packets with 188 bytes each. + * + * @demux: pointer to &struct dvb_demux + * @buf: buffer with data to be filtered + * @count: number of MPEG-TS packets with size of 188. + * + * The routine will discard a DVB packet that don't start with 0x47. + * + * Use this routine if the DVB demux fills MPEG-TS buffers that are + * already aligned. + * + * NOTE: The @buf size should have size equal to ``count * 188``. + */ +void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, + size_t count); + +/** + * dvb_dmx_swfilter - use dvb software filter for a buffer with + * multiple MPEG-TS packets with 188 bytes each. + * + * @demux: pointer to &struct dvb_demux + * @buf: buffer with data to be filtered + * @count: number of MPEG-TS packets with size of 188. + * + * If a DVB packet doesn't start with 0x47, it will seek for the first + * byte that starts with 0x47. + * + * Use this routine if the DVB demux fill buffers that may not start with + * a packet start mark (0x47). + * + * NOTE: The @buf size should have size equal to ``count * 188``. + */ +void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count); + +/** + * dvb_dmx_swfilter_204 - use dvb software filter for a buffer with + * multiple MPEG-TS packets with 204 bytes each. + * + * @demux: pointer to &struct dvb_demux + * @buf: buffer with data to be filtered + * @count: number of MPEG-TS packets with size of 204. + * + * If a DVB packet doesn't start with 0x47, it will seek for the first + * byte that starts with 0x47. + * + * Use this routine if the DVB demux fill buffers that may not start with + * a packet start mark (0x47). + * + * NOTE: The @buf size should have size equal to ``count * 204``. + */ +void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, + size_t count); + +/** + * dvb_dmx_swfilter_raw - make the raw data available to userspace without + * filtering + * + * @demux: pointer to &struct dvb_demux + * @buf: buffer with data + * @count: number of packets to be passed. The actual size of each packet + * depends on the &dvb_demux->feed->cb.ts logic. + * + * Use it if the driver needs to deliver the raw payload to userspace without + * passing through the kernel demux. That is meant to support some + * delivery systems that aren't based on MPEG-TS. + * + * This function relies on &dvb_demux->feed->cb.ts to actually handle the + * buffer. + */ +void dvb_dmx_swfilter_raw(struct dvb_demux *demux, const u8 *buf, + size_t count); + +#endif /* _DVB_DEMUX_H_ */ diff --git a/include/media/dvb_frontend.h b/include/media/dvb_frontend.h new file mode 100644 index 000000000000..0b40886fd7d3 --- /dev/null +++ b/include/media/dvb_frontend.h @@ -0,0 +1,795 @@ +/* + * dvb_frontend.h + * + * The Digital TV Frontend kABI defines a driver-internal interface for + * registering low-level, hardware specific driver to a hardware independent + * frontend layer. + * + * Copyright (C) 2001 convergence integrated media GmbH + * Copyright (C) 2004 convergence GmbH + * + * Written by Ralph Metzler + * Overhauled by Holger Waechtler + * Kernel I2C stuff by Michael Hunold + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#ifndef _DVB_FRONTEND_H_ +#define _DVB_FRONTEND_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +/* + * Maximum number of Delivery systems per frontend. It + * should be smaller or equal to 32 + */ +#define MAX_DELSYS 8 + +/** + * struct dvb_frontend_tune_settings - parameters to adjust frontend tuning + * + * @min_delay_ms: minimum delay for tuning, in ms + * @step_size: step size between two consecutive frequencies + * @max_drift: maximum drift + * + * NOTE: step_size is in Hz, for terrestrial/cable or kHz for satellite + */ +struct dvb_frontend_tune_settings { + int min_delay_ms; + int step_size; + int max_drift; +}; + +struct dvb_frontend; + +/** + * struct dvb_tuner_info - Frontend name and min/max ranges/bandwidths + * + * @name: name of the Frontend + * @frequency_min: minimal frequency supported + * @frequency_max: maximum frequency supported + * @frequency_step: frequency step + * @bandwidth_min: minimal frontend bandwidth supported + * @bandwidth_max: maximum frontend bandwidth supported + * @bandwidth_step: frontend bandwidth step + * + * NOTE: frequency parameters are in Hz, for terrestrial/cable or kHz for + * satellite. + */ +struct dvb_tuner_info { + char name[128]; + + u32 frequency_min; + u32 frequency_max; + u32 frequency_step; + + u32 bandwidth_min; + u32 bandwidth_max; + u32 bandwidth_step; +}; + +/** + * struct analog_parameters - Parameters to tune into an analog/radio channel + * + * @frequency: Frequency used by analog TV tuner (either in 62.5 kHz step, + * for TV, or 62.5 Hz for radio) + * @mode: Tuner mode, as defined on enum v4l2_tuner_type + * @audmode: Audio mode as defined for the rxsubchans field at videodev2.h, + * e. g. V4L2_TUNER_MODE_* + * @std: TV standard bitmap as defined at videodev2.h, e. g. V4L2_STD_* + * + * Hybrid tuners should be supported by both V4L2 and DVB APIs. This + * struct contains the data that are used by the V4L2 side. To avoid + * dependencies from V4L2 headers, all enums here are declared as integers. + */ +struct analog_parameters { + unsigned int frequency; + unsigned int mode; + unsigned int audmode; + u64 std; +}; + +/** + * enum dvbfe_algo - defines the algorithm used to tune into a channel + * + * @DVBFE_ALGO_HW: Hardware Algorithm - + * Devices that support this algorithm do everything in hardware + * and no software support is needed to handle them. + * Requesting these devices to LOCK is the only thing required, + * device is supposed to do everything in the hardware. + * + * @DVBFE_ALGO_SW: Software Algorithm - + * These are dumb devices, that require software to do everything + * + * @DVBFE_ALGO_CUSTOM: Customizable Agorithm - + * Devices having this algorithm can be customized to have specific + * algorithms in the frontend driver, rather than simply doing a + * software zig-zag. In this case the zigzag maybe hardware assisted + * or it maybe completely done in hardware. In all cases, usage of + * this algorithm, in conjunction with the search and track + * callbacks, utilizes the driver specific algorithm. + * + * @DVBFE_ALGO_RECOVERY: Recovery Algorithm - + * These devices have AUTO recovery capabilities from LOCK failure + */ +enum dvbfe_algo { + DVBFE_ALGO_HW = (1 << 0), + DVBFE_ALGO_SW = (1 << 1), + DVBFE_ALGO_CUSTOM = (1 << 2), + DVBFE_ALGO_RECOVERY = (1 << 31) +}; + +/** + * enum dvbfe_search - search callback possible return status + * + * @DVBFE_ALGO_SEARCH_SUCCESS: + * The frontend search algorithm completed and returned successfully + * + * @DVBFE_ALGO_SEARCH_ASLEEP: + * The frontend search algorithm is sleeping + * + * @DVBFE_ALGO_SEARCH_FAILED: + * The frontend search for a signal failed + * + * @DVBFE_ALGO_SEARCH_INVALID: + * The frontend search algorith was probably supplied with invalid + * parameters and the search is an invalid one + * + * @DVBFE_ALGO_SEARCH_ERROR: + * The frontend search algorithm failed due to some error + * + * @DVBFE_ALGO_SEARCH_AGAIN: + * The frontend search algorithm was requested to search again + */ +enum dvbfe_search { + DVBFE_ALGO_SEARCH_SUCCESS = (1 << 0), + DVBFE_ALGO_SEARCH_ASLEEP = (1 << 1), + DVBFE_ALGO_SEARCH_FAILED = (1 << 2), + DVBFE_ALGO_SEARCH_INVALID = (1 << 3), + DVBFE_ALGO_SEARCH_AGAIN = (1 << 4), + DVBFE_ALGO_SEARCH_ERROR = (1 << 31), +}; + +/** + * struct dvb_tuner_ops - Tuner information and callbacks + * + * @info: embedded &struct dvb_tuner_info with tuner properties + * @release: callback function called when frontend is detached. + * drivers should free any allocated memory. + * @init: callback function used to initialize the tuner device. + * @sleep: callback function used to put the tuner to sleep. + * @suspend: callback function used to inform that the Kernel will + * suspend. + * @resume: callback function used to inform that the Kernel is + * resuming from suspend. + * @set_params: callback function used to inform the tuner to tune + * into a digital TV channel. The properties to be used + * are stored at &struct dvb_frontend.dtv_property_cache. + * The tuner demod can change the parameters to reflect + * the changes needed for the channel to be tuned, and + * update statistics. This is the recommended way to set + * the tuner parameters and should be used on newer + * drivers. + * @set_analog_params: callback function used to tune into an analog TV + * channel on hybrid tuners. It passes @analog_parameters + * to the driver. + * @set_config: callback function used to send some tuner-specific + * parameters. + * @get_frequency: get the actual tuned frequency + * @get_bandwidth: get the bandwitdh used by the low pass filters + * @get_if_frequency: get the Intermediate Frequency, in Hz. For baseband, + * should return 0. + * @get_status: returns the frontend lock status + * @get_rf_strength: returns the RF signal strength. Used mostly to support + * analog TV and radio. Digital TV should report, instead, + * via DVBv5 API (&struct dvb_frontend.dtv_property_cache). + * @get_afc: Used only by analog TV core. Reports the frequency + * drift due to AFC. + * @calc_regs: callback function used to pass register data settings + * for simple tuners. Shouldn't be used on newer drivers. + * @set_frequency: Set a new frequency. Shouldn't be used on newer drivers. + * @set_bandwidth: Set a new frequency. Shouldn't be used on newer drivers. + * + * NOTE: frequencies used on @get_frequency and @set_frequency are in Hz for + * terrestrial/cable or kHz for satellite. + * + */ +struct dvb_tuner_ops { + + struct dvb_tuner_info info; + + void (*release)(struct dvb_frontend *fe); + int (*init)(struct dvb_frontend *fe); + int (*sleep)(struct dvb_frontend *fe); + int (*suspend)(struct dvb_frontend *fe); + int (*resume)(struct dvb_frontend *fe); + + /* This is the recomended way to set the tuner */ + int (*set_params)(struct dvb_frontend *fe); + int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p); + + int (*set_config)(struct dvb_frontend *fe, void *priv_cfg); + + int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency); + int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth); + int (*get_if_frequency)(struct dvb_frontend *fe, u32 *frequency); + +#define TUNER_STATUS_LOCKED 1 +#define TUNER_STATUS_STEREO 2 + int (*get_status)(struct dvb_frontend *fe, u32 *status); + int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength); + int (*get_afc)(struct dvb_frontend *fe, s32 *afc); + + /* + * This is support for demods like the mt352 - fills out the supplied + * buffer with what to write. + * + * Don't use on newer drivers. + */ + int (*calc_regs)(struct dvb_frontend *fe, u8 *buf, int buf_len); + + /* + * These are provided separately from set_params in order to + * facilitate silicon tuners which require sophisticated tuning loops, + * controlling each parameter separately. + * + * Don't use on newer drivers. + */ + int (*set_frequency)(struct dvb_frontend *fe, u32 frequency); + int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth); +}; + +/** + * struct analog_demod_info - Information struct for analog TV part of the demod + * + * @name: Name of the analog TV demodulator + */ +struct analog_demod_info { + char *name; +}; + +/** + * struct analog_demod_ops - Demodulation information and callbacks for + * analog TV and radio + * + * @info: pointer to struct analog_demod_info + * @set_params: callback function used to inform the demod to set the + * demodulator parameters needed to decode an analog or + * radio channel. The properties are passed via + * &struct analog_params. + * @has_signal: returns 0xffff if has signal, or 0 if it doesn't. + * @get_afc: Used only by analog TV core. Reports the frequency + * drift due to AFC. + * @tuner_status: callback function that returns tuner status bits, e. g. + * %TUNER_STATUS_LOCKED and %TUNER_STATUS_STEREO. + * @standby: set the tuner to standby mode. + * @release: callback function called when frontend is detached. + * drivers should free any allocated memory. + * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C + * mux support instead. + * @set_config: callback function used to send some tuner-specific + * parameters. + */ +struct analog_demod_ops { + + struct analog_demod_info info; + + void (*set_params)(struct dvb_frontend *fe, + struct analog_parameters *params); + int (*has_signal)(struct dvb_frontend *fe, u16 *signal); + int (*get_afc)(struct dvb_frontend *fe, s32 *afc); + void (*tuner_status)(struct dvb_frontend *fe); + void (*standby)(struct dvb_frontend *fe); + void (*release)(struct dvb_frontend *fe); + int (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable); + + /** This is to allow setting tuner-specific configuration */ + int (*set_config)(struct dvb_frontend *fe, void *priv_cfg); +}; + +struct dtv_frontend_properties; + + +/** + * struct dvb_frontend_ops - Demodulation information and callbacks for + * ditialt TV + * + * @info: embedded &struct dvb_tuner_info with tuner properties + * @delsys: Delivery systems supported by the frontend + * @detach: callback function called when frontend is detached. + * drivers should clean up, but not yet free the &struct + * dvb_frontend allocation. + * @release: callback function called when frontend is ready to be + * freed. + * drivers should free any allocated memory. + * @release_sec: callback function requesting that the Satelite Equipment + * Control (SEC) driver to release and free any memory + * allocated by the driver. + * @init: callback function used to initialize the tuner device. + * @sleep: callback function used to put the tuner to sleep. + * @write: callback function used by some demod legacy drivers to + * allow other drivers to write data into their registers. + * Should not be used on new drivers. + * @tune: callback function used by demod drivers that use + * @DVBFE_ALGO_HW to tune into a frequency. + * @get_frontend_algo: returns the desired hardware algorithm. + * @set_frontend: callback function used to inform the demod to set the + * parameters for demodulating a digital TV channel. + * The properties to be used are stored at &struct + * dvb_frontend.dtv_property_cache. The demod can change + * the parameters to reflect the changes needed for the + * channel to be decoded, and update statistics. + * @get_tune_settings: callback function + * @get_frontend: callback function used to inform the parameters + * actuall in use. The properties to be used are stored at + * &struct dvb_frontend.dtv_property_cache and update + * statistics. Please notice that it should not return + * an error code if the statistics are not available + * because the demog is not locked. + * @read_status: returns the locking status of the frontend. + * @read_ber: legacy callback function to return the bit error rate. + * Newer drivers should provide such info via DVBv5 API, + * e. g. @set_frontend;/@get_frontend, implementing this + * callback only if DVBv3 API compatibility is wanted. + * @read_signal_strength: legacy callback function to return the signal + * strength. Newer drivers should provide such info via + * DVBv5 API, e. g. @set_frontend/@get_frontend, + * implementing this callback only if DVBv3 API + * compatibility is wanted. + * @read_snr: legacy callback function to return the Signal/Noise + * rate. Newer drivers should provide such info via + * DVBv5 API, e. g. @set_frontend/@get_frontend, + * implementing this callback only if DVBv3 API + * compatibility is wanted. + * @read_ucblocks: legacy callback function to return the Uncorrected Error + * Blocks. Newer drivers should provide such info via + * DVBv5 API, e. g. @set_frontend/@get_frontend, + * implementing this callback only if DVBv3 API + * compatibility is wanted. + * @diseqc_reset_overload: callback function to implement the + * FE_DISEQC_RESET_OVERLOAD() ioctl (only Satellite) + * @diseqc_send_master_cmd: callback function to implement the + * FE_DISEQC_SEND_MASTER_CMD() ioctl (only Satellite). + * @diseqc_recv_slave_reply: callback function to implement the + * FE_DISEQC_RECV_SLAVE_REPLY() ioctl (only Satellite) + * @diseqc_send_burst: callback function to implement the + * FE_DISEQC_SEND_BURST() ioctl (only Satellite). + * @set_tone: callback function to implement the + * FE_SET_TONE() ioctl (only Satellite). + * @set_voltage: callback function to implement the + * FE_SET_VOLTAGE() ioctl (only Satellite). + * @enable_high_lnb_voltage: callback function to implement the + * FE_ENABLE_HIGH_LNB_VOLTAGE() ioctl (only Satellite). + * @dishnetwork_send_legacy_command: callback function to implement the + * FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl (only Satellite). + * Drivers should not use this, except when the DVB + * core emulation fails to provide proper support (e.g. + * if @set_voltage takes more than 8ms to work), and + * when backward compatibility with this legacy API is + * required. + * @i2c_gate_ctrl: controls the I2C gate. Newer drivers should use I2C + * mux support instead. + * @ts_bus_ctrl: callback function used to take control of the TS bus. + * @set_lna: callback function to power on/off/auto the LNA. + * @search: callback function used on some custom algo search algos. + * @tuner_ops: pointer to &struct dvb_tuner_ops + * @analog_ops: pointer to &struct analog_demod_ops + */ +struct dvb_frontend_ops { + struct dvb_frontend_info info; + + u8 delsys[MAX_DELSYS]; + + void (*detach)(struct dvb_frontend *fe); + void (*release)(struct dvb_frontend* fe); + void (*release_sec)(struct dvb_frontend* fe); + + int (*init)(struct dvb_frontend* fe); + int (*sleep)(struct dvb_frontend* fe); + + int (*write)(struct dvb_frontend* fe, const u8 buf[], int len); + + /* if this is set, it overrides the default swzigzag */ + int (*tune)(struct dvb_frontend* fe, + bool re_tune, + unsigned int mode_flags, + unsigned int *delay, + enum fe_status *status); + + /* get frontend tuning algorithm from the module */ + enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe); + + /* these two are only used for the swzigzag code */ + int (*set_frontend)(struct dvb_frontend *fe); + int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings); + + int (*get_frontend)(struct dvb_frontend *fe, + struct dtv_frontend_properties *props); + + int (*read_status)(struct dvb_frontend *fe, enum fe_status *status); + int (*read_ber)(struct dvb_frontend* fe, u32* ber); + int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength); + int (*read_snr)(struct dvb_frontend* fe, u16* snr); + int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks); + + int (*diseqc_reset_overload)(struct dvb_frontend* fe); + int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd); + int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply); + int (*diseqc_send_burst)(struct dvb_frontend *fe, + enum fe_sec_mini_cmd minicmd); + int (*set_tone)(struct dvb_frontend *fe, enum fe_sec_tone_mode tone); + int (*set_voltage)(struct dvb_frontend *fe, + enum fe_sec_voltage voltage); + int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg); + int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd); + int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable); + int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire); + int (*set_lna)(struct dvb_frontend *); + + /* + * These callbacks are for devices that implement their own + * tuning algorithms, rather than a simple swzigzag + */ + enum dvbfe_search (*search)(struct dvb_frontend *fe); + + struct dvb_tuner_ops tuner_ops; + struct analog_demod_ops analog_ops; +}; + +#ifdef __DVB_CORE__ +#define MAX_EVENT 8 + +/* Used only internally at dvb_frontend.c */ +struct dvb_fe_events { + struct dvb_frontend_event events[MAX_EVENT]; + int eventw; + int eventr; + int overflow; + wait_queue_head_t wait_queue; + struct mutex mtx; +}; +#endif + +/** + * struct dtv_frontend_properties - contains a list of properties that are + * specific to a digital TV standard. + * + * @frequency: frequency in Hz for terrestrial/cable or in kHz for + * Satellite + * @modulation: Frontend modulation type + * @voltage: SEC voltage (only Satellite) + * @sectone: SEC tone mode (only Satellite) + * @inversion: Spectral inversion + * @fec_inner: Forward error correction inner Code Rate + * @transmission_mode: Transmission Mode + * @bandwidth_hz: Bandwidth, in Hz. A zero value means that userspace + * wants to autodetect. + * @guard_interval: Guard Interval + * @hierarchy: Hierarchy + * @symbol_rate: Symbol Rate + * @code_rate_HP: high priority stream code rate + * @code_rate_LP: low priority stream code rate + * @pilot: Enable/disable/autodetect pilot tones + * @rolloff: Rolloff factor (alpha) + * @delivery_system: FE delivery system (e. g. digital TV standard) + * @interleaving: interleaving + * @isdbt_partial_reception: ISDB-T partial reception (only ISDB standard) + * @isdbt_sb_mode: ISDB-T Sound Broadcast (SB) mode (only ISDB standard) + * @isdbt_sb_subchannel: ISDB-T SB subchannel (only ISDB standard) + * @isdbt_sb_segment_idx: ISDB-T SB segment index (only ISDB standard) + * @isdbt_sb_segment_count: ISDB-T SB segment count (only ISDB standard) + * @isdbt_layer_enabled: ISDB Layer enabled (only ISDB standard) + * @layer: ISDB per-layer data (only ISDB standard) + * @layer.segment_count: Segment Count; + * @layer.fec: per layer code rate; + * @layer.modulation: per layer modulation; + * @layer.interleaving: per layer interleaving. + * @stream_id: If different than zero, enable substream filtering, if + * hardware supports (DVB-S2 and DVB-T2). + * @scrambling_sequence_index: Carries the index of the DVB-S2 physical layer + * scrambling sequence. + * @atscmh_fic_ver: Version number of the FIC (Fast Information Channel) + * signaling data (only ATSC-M/H) + * @atscmh_parade_id: Parade identification number (only ATSC-M/H) + * @atscmh_nog: Number of MH groups per MH subframe for a designated + * parade (only ATSC-M/H) + * @atscmh_tnog: Total number of MH groups including all MH groups + * belonging to all MH parades in one MH subframe + * (only ATSC-M/H) + * @atscmh_sgn: Start group number (only ATSC-M/H) + * @atscmh_prc: Parade repetition cycle (only ATSC-M/H) + * @atscmh_rs_frame_mode: Reed Solomon (RS) frame mode (only ATSC-M/H) + * @atscmh_rs_frame_ensemble: RS frame ensemble (only ATSC-M/H) + * @atscmh_rs_code_mode_pri: RS code mode pri (only ATSC-M/H) + * @atscmh_rs_code_mode_sec: RS code mode sec (only ATSC-M/H) + * @atscmh_sccc_block_mode: Series Concatenated Convolutional Code (SCCC) + * Block Mode (only ATSC-M/H) + * @atscmh_sccc_code_mode_a: SCCC code mode A (only ATSC-M/H) + * @atscmh_sccc_code_mode_b: SCCC code mode B (only ATSC-M/H) + * @atscmh_sccc_code_mode_c: SCCC code mode C (only ATSC-M/H) + * @atscmh_sccc_code_mode_d: SCCC code mode D (only ATSC-M/H) + * @lna: Power ON/OFF/AUTO the Linear Now-noise Amplifier (LNA) + * @strength: DVBv5 API statistics: Signal Strength + * @cnr: DVBv5 API statistics: Signal to Noise ratio of the + * (main) carrier + * @pre_bit_error: DVBv5 API statistics: pre-Viterbi bit error count + * @pre_bit_count: DVBv5 API statistics: pre-Viterbi bit count + * @post_bit_error: DVBv5 API statistics: post-Viterbi bit error count + * @post_bit_count: DVBv5 API statistics: post-Viterbi bit count + * @block_error: DVBv5 API statistics: block error count + * @block_count: DVBv5 API statistics: block count + * + * NOTE: derivated statistics like Uncorrected Error blocks (UCE) are + * calculated on userspace. + * + * Only a subset of the properties are needed for a given delivery system. + * For more info, consult the media_api.html with the documentation of the + * Userspace API. + */ +struct dtv_frontend_properties { + u32 frequency; + enum fe_modulation modulation; + + enum fe_sec_voltage voltage; + enum fe_sec_tone_mode sectone; + enum fe_spectral_inversion inversion; + enum fe_code_rate fec_inner; + enum fe_transmit_mode transmission_mode; + u32 bandwidth_hz; /* 0 = AUTO */ + enum fe_guard_interval guard_interval; + enum fe_hierarchy hierarchy; + u32 symbol_rate; + enum fe_code_rate code_rate_HP; + enum fe_code_rate code_rate_LP; + + enum fe_pilot pilot; + enum fe_rolloff rolloff; + + enum fe_delivery_system delivery_system; + + enum fe_interleaving interleaving; + + /* ISDB-T specifics */ + u8 isdbt_partial_reception; + u8 isdbt_sb_mode; + u8 isdbt_sb_subchannel; + u32 isdbt_sb_segment_idx; + u32 isdbt_sb_segment_count; + u8 isdbt_layer_enabled; + struct { + u8 segment_count; + enum fe_code_rate fec; + enum fe_modulation modulation; + u8 interleaving; + } layer[3]; + + /* Multistream specifics */ + u32 stream_id; + + /* Physical Layer Scrambling specifics */ + u32 scrambling_sequence_index; + + /* ATSC-MH specifics */ + u8 atscmh_fic_ver; + u8 atscmh_parade_id; + u8 atscmh_nog; + u8 atscmh_tnog; + u8 atscmh_sgn; + u8 atscmh_prc; + + u8 atscmh_rs_frame_mode; + u8 atscmh_rs_frame_ensemble; + u8 atscmh_rs_code_mode_pri; + u8 atscmh_rs_code_mode_sec; + u8 atscmh_sccc_block_mode; + u8 atscmh_sccc_code_mode_a; + u8 atscmh_sccc_code_mode_b; + u8 atscmh_sccc_code_mode_c; + u8 atscmh_sccc_code_mode_d; + + u32 lna; + + /* statistics data */ + struct dtv_fe_stats strength; + struct dtv_fe_stats cnr; + struct dtv_fe_stats pre_bit_error; + struct dtv_fe_stats pre_bit_count; + struct dtv_fe_stats post_bit_error; + struct dtv_fe_stats post_bit_count; + struct dtv_fe_stats block_error; + struct dtv_fe_stats block_count; +}; + +#define DVB_FE_NO_EXIT 0 +#define DVB_FE_NORMAL_EXIT 1 +#define DVB_FE_DEVICE_REMOVED 2 +#define DVB_FE_DEVICE_RESUME 3 + +/** + * struct dvb_frontend - Frontend structure to be used on drivers. + * + * @refcount: refcount to keep track of &struct dvb_frontend + * references + * @ops: embedded &struct dvb_frontend_ops + * @dvb: pointer to &struct dvb_adapter + * @demodulator_priv: demod private data + * @tuner_priv: tuner private data + * @frontend_priv: frontend private data + * @sec_priv: SEC private data + * @analog_demod_priv: Analog demod private data + * @dtv_property_cache: embedded &struct dtv_frontend_properties + * @callback: callback function used on some drivers to call + * either the tuner or the demodulator. + * @id: Frontend ID + * @exit: Used to inform the DVB core that the frontend + * thread should exit (usually, means that the hardware + * got disconnected. + */ + +struct dvb_frontend { + struct kref refcount; + struct dvb_frontend_ops ops; + struct dvb_adapter *dvb; + void *demodulator_priv; + void *tuner_priv; + void *frontend_priv; + void *sec_priv; + void *analog_demod_priv; + struct dtv_frontend_properties dtv_property_cache; +#define DVB_FRONTEND_COMPONENT_TUNER 0 +#define DVB_FRONTEND_COMPONENT_DEMOD 1 + int (*callback)(void *adapter_priv, int component, int cmd, int arg); + int id; + unsigned int exit; +}; + +/** + * dvb_register_frontend() - Registers a DVB frontend at the adapter + * + * @dvb: pointer to &struct dvb_adapter + * @fe: pointer to &struct dvb_frontend + * + * Allocate and initialize the private data needed by the frontend core to + * manage the frontend and calls dvb_register_device() to register a new + * frontend. It also cleans the property cache that stores the frontend + * parameters and selects the first available delivery system. + */ +int dvb_register_frontend(struct dvb_adapter *dvb, + struct dvb_frontend *fe); + +/** + * dvb_unregister_frontend() - Unregisters a DVB frontend + * + * @fe: pointer to &struct dvb_frontend + * + * Stops the frontend kthread, calls dvb_unregister_device() and frees the + * private frontend data allocated by dvb_register_frontend(). + * + * NOTE: This function doesn't frees the memory allocated by the demod, + * by the SEC driver and by the tuner. In order to free it, an explicit call to + * dvb_frontend_detach() is needed, after calling this function. + */ +int dvb_unregister_frontend(struct dvb_frontend *fe); + +/** + * dvb_frontend_detach() - Detaches and frees frontend specific data + * + * @fe: pointer to &struct dvb_frontend + * + * This function should be called after dvb_unregister_frontend(). It + * calls the SEC, tuner and demod release functions: + * &dvb_frontend_ops.release_sec, &dvb_frontend_ops.tuner_ops.release, + * &dvb_frontend_ops.analog_ops.release and &dvb_frontend_ops.release. + * + * If the driver is compiled with %CONFIG_MEDIA_ATTACH, it also decreases + * the module reference count, needed to allow userspace to remove the + * previously used DVB frontend modules. + */ +void dvb_frontend_detach(struct dvb_frontend *fe); + +/** + * dvb_frontend_suspend() - Suspends a Digital TV frontend + * + * @fe: pointer to &struct dvb_frontend + * + * This function prepares a Digital TV frontend to suspend. + * + * In order to prepare the tuner to suspend, if + * &dvb_frontend_ops.tuner_ops.suspend\(\) is available, it calls it. Otherwise, + * it will call &dvb_frontend_ops.tuner_ops.sleep\(\), if available. + * + * It will also call &dvb_frontend_ops.sleep\(\) to put the demod to suspend. + * + * The drivers should also call dvb_frontend_suspend\(\) as part of their + * handler for the &device_driver.suspend\(\). + */ +int dvb_frontend_suspend(struct dvb_frontend *fe); + +/** + * dvb_frontend_resume() - Resumes a Digital TV frontend + * + * @fe: pointer to &struct dvb_frontend + * + * This function resumes the usual operation of the tuner after resume. + * + * In order to resume the frontend, it calls the demod &dvb_frontend_ops.init\(\). + * + * If &dvb_frontend_ops.tuner_ops.resume\(\) is available, It, it calls it. + * Otherwise,t will call &dvb_frontend_ops.tuner_ops.init\(\), if available. + * + * Once tuner and demods are resumed, it will enforce that the SEC voltage and + * tone are restored to their previous values and wake up the frontend's + * kthread in order to retune the frontend. + * + * The drivers should also call dvb_frontend_resume() as part of their + * handler for the &device_driver.resume\(\). + */ +int dvb_frontend_resume(struct dvb_frontend *fe); + +/** + * dvb_frontend_reinitialise() - forces a reinitialisation at the frontend + * + * @fe: pointer to &struct dvb_frontend + * + * Calls &dvb_frontend_ops.init\(\) and &dvb_frontend_ops.tuner_ops.init\(\), + * and resets SEC tone and voltage (for Satellite systems). + * + * NOTE: Currently, this function is used only by one driver (budget-av). + * It seems to be due to address some special issue with that specific + * frontend. + */ +void dvb_frontend_reinitialise(struct dvb_frontend *fe); + +/** + * dvb_frontend_sleep_until() - Sleep for the amount of time given by + * add_usec parameter + * + * @waketime: pointer to &struct ktime_t + * @add_usec: time to sleep, in microseconds + * + * This function is used to measure the time required for the + * FE_DISHNETWORK_SEND_LEGACY_CMD() ioctl to work. It needs to be as precise + * as possible, as it affects the detection of the dish tone command at the + * satellite subsystem. + * + * Its used internally by the DVB frontend core, in order to emulate + * FE_DISHNETWORK_SEND_LEGACY_CMD() using the &dvb_frontend_ops.set_voltage\(\) + * callback. + * + * NOTE: it should not be used at the drivers, as the emulation for the + * legacy callback is provided by the Kernel. The only situation where this + * should be at the drivers is when there are some bugs at the hardware that + * would prevent the core emulation to work. On such cases, the driver would + * be writing a &dvb_frontend_ops.dishnetwork_send_legacy_command\(\) and + * calling this function directly. + */ +void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec); + +#endif diff --git a/include/media/dvb_math.h b/include/media/dvb_math.h new file mode 100644 index 000000000000..8690ec42954d --- /dev/null +++ b/include/media/dvb_math.h @@ -0,0 +1,66 @@ +/* + * dvb-math provides some complex fixed-point math + * operations shared between the dvb related stuff + * + * Copyright (C) 2006 Christoph Pfister (christophpfister@gmail.com) + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#ifndef __DVB_MATH_H +#define __DVB_MATH_H + +#include + +/** + * intlog2 - computes log2 of a value; the result is shifted left by 24 bits + * + * @value: The value (must be != 0) + * + * to use rational values you can use the following method: + * + * intlog2(value) = intlog2(value * 2^x) - x * 2^24 + * + * Some usecase examples: + * + * intlog2(8) will give 3 << 24 = 3 * 2^24 + * + * intlog2(9) will give 3 << 24 + ... = 3.16... * 2^24 + * + * intlog2(1.5) = intlog2(3) - 2^24 = 0.584... * 2^24 + * + * + * return: log2(value) * 2^24 + */ +extern unsigned int intlog2(u32 value); + +/** + * intlog10 - computes log10 of a value; the result is shifted left by 24 bits + * + * @value: The value (must be != 0) + * + * to use rational values you can use the following method: + * + * intlog10(value) = intlog10(value * 10^x) - x * 2^24 + * + * An usecase example: + * + * intlog10(1000) will give 3 << 24 = 3 * 2^24 + * + * due to the implementation intlog10(1000) might be not exactly 3 * 2^24 + * + * look at intlog2 for similar examples + * + * return: log10(value) * 2^24 + */ +extern unsigned int intlog10(u32 value); + +#endif diff --git a/include/media/dvb_net.h b/include/media/dvb_net.h new file mode 100644 index 000000000000..5e31d37f25fa --- /dev/null +++ b/include/media/dvb_net.h @@ -0,0 +1,93 @@ +/* + * dvb_net.h + * + * Copyright (C) 2001 Ralph Metzler for convergence integrated media GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _DVB_NET_H_ +#define _DVB_NET_H_ + +#include +#include +#include +#include +#include + +#include + +#define DVB_NET_DEVICES_MAX 10 + +#ifdef CONFIG_DVB_NET + +/** + * struct dvb_net - describes a DVB network interface + * + * @dvbdev: pointer to &struct dvb_device. + * @device: array of pointers to &struct net_device. + * @state: array of integers to each net device. A value + * different than zero means that the interface is + * in usage. + * @exit: flag to indicate when the device is being removed. + * @demux: pointer to &struct dmx_demux. + * @ioctl_mutex: protect access to this struct. + * + * Currently, the core supports up to %DVB_NET_DEVICES_MAX (10) network + * devices. + */ + +struct dvb_net { + struct dvb_device *dvbdev; + struct net_device *device[DVB_NET_DEVICES_MAX]; + int state[DVB_NET_DEVICES_MAX]; + unsigned int exit:1; + struct dmx_demux *demux; + struct mutex ioctl_mutex; +}; + +/** + * dvb_net_init - nitializes a digital TV network device and registers it. + * + * @adap: pointer to &struct dvb_adapter. + * @dvbnet: pointer to &struct dvb_net. + * @dmxdemux: pointer to &struct dmx_demux. + */ +int dvb_net_init(struct dvb_adapter *adap, struct dvb_net *dvbnet, + struct dmx_demux *dmxdemux); + +/** + * dvb_net_release - releases a digital TV network device and unregisters it. + * + * @dvbnet: pointer to &struct dvb_net. + */ +void dvb_net_release(struct dvb_net *dvbnet); + +#else + +struct dvb_net { + struct dvb_device *dvbdev; +}; + +static inline void dvb_net_release(struct dvb_net *dvbnet) +{ +} + +static inline int dvb_net_init(struct dvb_adapter *adap, + struct dvb_net *dvbnet, struct dmx_demux *dmx) +{ + return 0; +} + +#endif /* ifdef CONFIG_DVB_NET */ + +#endif diff --git a/include/media/dvb_ringbuffer.h b/include/media/dvb_ringbuffer.h new file mode 100644 index 000000000000..8ed6bcc3a56e --- /dev/null +++ b/include/media/dvb_ringbuffer.h @@ -0,0 +1,280 @@ +/* + * + * dvb_ringbuffer.h: ring buffer implementation for the dvb driver + * + * Copyright (C) 2003 Oliver Endriss + * Copyright (C) 2004 Andrew de Quincey + * + * based on code originally found in av7110.c & dvb_ci.c: + * Copyright (C) 1999-2003 Ralph Metzler & Marcus Metzler + * for convergence integrated media GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#ifndef _DVB_RINGBUFFER_H_ +#define _DVB_RINGBUFFER_H_ + +#include +#include + +/** + * struct dvb_ringbuffer - Describes a ring buffer used at DVB framework + * + * @data: Area were the ringbuffer data is written + * @size: size of the ringbuffer + * @pread: next position to read + * @pwrite: next position to write + * @error: used by ringbuffer clients to indicate that an error happened. + * @queue: Wait queue used by ringbuffer clients to indicate when buffer + * was filled + * @lock: Spinlock used to protect the ringbuffer + */ +struct dvb_ringbuffer { + u8 *data; + ssize_t size; + ssize_t pread; + ssize_t pwrite; + int error; + + wait_queue_head_t queue; + spinlock_t lock; +}; + +#define DVB_RINGBUFFER_PKTHDRSIZE 3 + +/** + * dvb_ringbuffer_init - initialize ring buffer, lock and queue + * + * @rbuf: pointer to struct dvb_ringbuffer + * @data: pointer to the buffer where the data will be stored + * @len: bytes from ring buffer into @buf + */ +extern void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void *data, + size_t len); + +/** + * dvb_ringbuffer_empty - test whether buffer is empty + * + * @rbuf: pointer to struct dvb_ringbuffer + */ +extern int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf); + +/** + * dvb_ringbuffer_free - returns the number of free bytes in the buffer + * + * @rbuf: pointer to struct dvb_ringbuffer + * + * Return: number of free bytes in the buffer + */ +extern ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf); + +/** + * dvb_ringbuffer_avail - returns the number of bytes waiting in the buffer + * + * @rbuf: pointer to struct dvb_ringbuffer + * + * Return: number of bytes waiting in the buffer + */ +extern ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf); + +/** + * dvb_ringbuffer_reset - resets the ringbuffer to initial state + * + * @rbuf: pointer to struct dvb_ringbuffer + * + * Resets the read and write pointers to zero and flush the buffer. + * + * This counts as a read and write operation + */ +extern void dvb_ringbuffer_reset(struct dvb_ringbuffer *rbuf); + +/* + * read routines & macros + */ + +/** + * dvb_ringbuffer_flush - flush buffer + * + * @rbuf: pointer to struct dvb_ringbuffer + */ +extern void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf); + +/** + * dvb_ringbuffer_flush_spinlock_wakeup- flush buffer protected by spinlock + * and wake-up waiting task(s) + * + * @rbuf: pointer to struct dvb_ringbuffer + */ +extern void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf); + +/** + * DVB_RINGBUFFER_PEEK - peek at byte @offs in the buffer + * + * @rbuf: pointer to struct dvb_ringbuffer + * @offs: offset inside the ringbuffer + */ +#define DVB_RINGBUFFER_PEEK(rbuf, offs) \ + ((rbuf)->data[((rbuf)->pread + (offs)) % (rbuf)->size]) + +/** + * DVB_RINGBUFFER_SKIP - advance read ptr by @num bytes + * + * @rbuf: pointer to struct dvb_ringbuffer + * @num: number of bytes to advance + */ +#define DVB_RINGBUFFER_SKIP(rbuf, num) {\ + (rbuf)->pread = ((rbuf)->pread + (num)) % (rbuf)->size;\ +} + +/** + * dvb_ringbuffer_read_user - Reads a buffer into a user pointer + * + * @rbuf: pointer to struct dvb_ringbuffer + * @buf: pointer to the buffer where the data will be stored + * @len: bytes from ring buffer into @buf + * + * This variant assumes that the buffer is a memory at the userspace. So, + * it will internally call copy_to_user(). + * + * Return: number of bytes transferred or -EFAULT + */ +extern ssize_t dvb_ringbuffer_read_user(struct dvb_ringbuffer *rbuf, + u8 __user *buf, size_t len); + +/** + * dvb_ringbuffer_read - Reads a buffer into a pointer + * + * @rbuf: pointer to struct dvb_ringbuffer + * @buf: pointer to the buffer where the data will be stored + * @len: bytes from ring buffer into @buf + * + * This variant assumes that the buffer is a memory at the Kernel space + * + * Return: number of bytes transferred or -EFAULT + */ +extern void dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, + u8 *buf, size_t len); + +/* + * write routines & macros + */ + +/** + * DVB_RINGBUFFER_WRITE_BYTE - write single byte to ring buffer + * + * @rbuf: pointer to struct dvb_ringbuffer + * @byte: byte to write + */ +#define DVB_RINGBUFFER_WRITE_BYTE(rbuf, byte) \ + { (rbuf)->data[(rbuf)->pwrite] = (byte); \ + (rbuf)->pwrite = ((rbuf)->pwrite + 1) % (rbuf)->size; } + +/** + * dvb_ringbuffer_write - Writes a buffer into the ringbuffer + * + * @rbuf: pointer to struct dvb_ringbuffer + * @buf: pointer to the buffer where the data will be read + * @len: bytes from ring buffer into @buf + * + * This variant assumes that the buffer is a memory at the Kernel space + * + * return: number of bytes transferred or -EFAULT + */ +extern ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf, + size_t len); + +/** + * dvb_ringbuffer_write_user - Writes a buffer received via a user pointer + * + * @rbuf: pointer to struct dvb_ringbuffer + * @buf: pointer to the buffer where the data will be read + * @len: bytes from ring buffer into @buf + * + * This variant assumes that the buffer is a memory at the userspace. So, + * it will internally call copy_from_user(). + * + * Return: number of bytes transferred or -EFAULT + */ +extern ssize_t dvb_ringbuffer_write_user(struct dvb_ringbuffer *rbuf, + const u8 __user *buf, size_t len); + +/** + * dvb_ringbuffer_pkt_write - Write a packet into the ringbuffer. + * + * @rbuf: Ringbuffer to write to. + * @buf: Buffer to write. + * @len: Length of buffer (currently limited to 65535 bytes max). + * + * Return: Number of bytes written, or -EFAULT, -ENOMEM, -EVINAL. + */ +extern ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8 *buf, + size_t len); + +/** + * dvb_ringbuffer_pkt_read_user - Read from a packet in the ringbuffer. + * + * @rbuf: Ringbuffer concerned. + * @idx: Packet index as returned by dvb_ringbuffer_pkt_next(). + * @offset: Offset into packet to read from. + * @buf: Destination buffer for data. + * @len: Size of destination buffer. + * + * Return: Number of bytes read, or -EFAULT. + * + * .. note:: + * + * unlike dvb_ringbuffer_read(), this does **NOT** update the read pointer + * in the ringbuffer. You must use dvb_ringbuffer_pkt_dispose() to mark a + * packet as no longer required. + */ +extern ssize_t dvb_ringbuffer_pkt_read_user(struct dvb_ringbuffer *rbuf, + size_t idx, + int offset, u8 __user *buf, + size_t len); + +/** + * dvb_ringbuffer_pkt_read - Read from a packet in the ringbuffer. + * Note: unlike dvb_ringbuffer_read_user(), this DOES update the read pointer + * in the ringbuffer. + * + * @rbuf: Ringbuffer concerned. + * @idx: Packet index as returned by dvb_ringbuffer_pkt_next(). + * @offset: Offset into packet to read from. + * @buf: Destination buffer for data. + * @len: Size of destination buffer. + * + * Return: Number of bytes read, or -EFAULT. + */ +extern ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx, + int offset, u8 *buf, size_t len); + +/** + * dvb_ringbuffer_pkt_dispose - Dispose of a packet in the ring buffer. + * + * @rbuf: Ring buffer concerned. + * @idx: Packet index as returned by dvb_ringbuffer_pkt_next(). + */ +extern void dvb_ringbuffer_pkt_dispose(struct dvb_ringbuffer *rbuf, size_t idx); + +/** + * dvb_ringbuffer_pkt_next - Get the index of the next packet in a ringbuffer. + * + * @rbuf: Ringbuffer concerned. + * @idx: Previous packet index, or -1 to return the first packet index. + * @pktlen: On success, will be updated to contain the length of the packet + * in bytes. + * returns Packet index (if >=0), or -1 if no packets available. + */ +extern ssize_t dvb_ringbuffer_pkt_next(struct dvb_ringbuffer *rbuf, + size_t idx, size_t *pktlen); + +#endif /* _DVB_RINGBUFFER_H_ */ diff --git a/include/media/dvb_vb2.h b/include/media/dvb_vb2.h new file mode 100644 index 000000000000..7a529844c5e1 --- /dev/null +++ b/include/media/dvb_vb2.h @@ -0,0 +1,96 @@ +/* + * SPDX-License-Identifier: GPL-2.0 + * + * dvb-vb2.h - DVB driver helper framework for streaming I/O + * + * Copyright (C) 2015 Samsung Electronics + * + * Author: jh1009.sung@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + */ + +#ifndef _DVB_VB2_H +#define _DVB_VB2_H + +#include +#include +#include +#include +#include +#include + +enum dvb_buf_type { + DVB_BUF_TYPE_CAPTURE = 1, + DVB_BUF_TYPE_OUTPUT = 2, +}; + +#define DVB_VB2_STATE_NONE (0x0) +#define DVB_VB2_STATE_INIT (0x1) +#define DVB_VB2_STATE_REQBUFS (0x2) +#define DVB_VB2_STATE_STREAMON (0x4) + +#define DVB_VB2_NAME_MAX (20) + +struct dvb_buffer { + struct vb2_buffer vb; + struct list_head list; +}; + +struct dvb_vb2_ctx { + struct vb2_queue vb_q; + struct mutex mutex; + spinlock_t slock; + struct list_head dvb_q; + struct dvb_buffer *buf; + int offset; + int remain; + int state; + int buf_siz; + int buf_cnt; + int nonblocking; + char name[DVB_VB2_NAME_MAX + 1]; +}; + +int dvb_vb2_stream_on(struct dvb_vb2_ctx *ctx); +int dvb_vb2_stream_off(struct dvb_vb2_ctx *ctx); +#ifndef DVB_MMAP +static inline int dvb_vb2_init(struct dvb_vb2_ctx *ctx, + const char *name, int non_blocking) +{ + return 0; +}; +static inline int dvb_vb2_release(struct dvb_vb2_ctx *ctx) +{ + return 0; +}; +#define dvb_vb2_is_streaming(ctx) (0) +#define dvb_vb2_fill_buffer(ctx, file, wait) (0) + +static inline unsigned int dvb_vb2_poll(struct dvb_vb2_ctx *ctx, + struct file *file, + poll_table *wait) +{ + return 0; +} +#else +int dvb_vb2_init(struct dvb_vb2_ctx *ctx, const char *name, int non_blocking); +int dvb_vb2_release(struct dvb_vb2_ctx *ctx); +int dvb_vb2_is_streaming(struct dvb_vb2_ctx *ctx); +int dvb_vb2_fill_buffer(struct dvb_vb2_ctx *ctx, + const unsigned char *src, int len); +unsigned int dvb_vb2_poll(struct dvb_vb2_ctx *ctx, struct file *file, + poll_table *wait); +#endif + + +int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req); +int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); +int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp); +int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); +int dvb_vb2_dqbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); +int dvb_vb2_mmap(struct dvb_vb2_ctx *ctx, struct vm_area_struct *vma); + +#endif /* _DVB_VB2_H */ diff --git a/include/media/dvbdev.h b/include/media/dvbdev.h new file mode 100644 index 000000000000..bbc1c20c0529 --- /dev/null +++ b/include/media/dvbdev.h @@ -0,0 +1,407 @@ +/* + * dvbdev.h + * + * Copyright (C) 2000 Ralph Metzler & Marcus Metzler + * for convergence integrated media GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Lesser Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _DVBDEV_H_ +#define _DVBDEV_H_ + +#include +#include +#include +#include +#include + +#define DVB_MAJOR 212 + +#if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0 + #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS +#else + #define DVB_MAX_ADAPTERS 16 +#endif + +#define DVB_UNSET (-1) + +/* List of DVB device types */ + +/** + * enum dvb_device_type - type of the Digital TV device + * + * @DVB_DEVICE_SEC: Digital TV standalone Common Interface (CI) + * @DVB_DEVICE_FRONTEND: Digital TV frontend. + * @DVB_DEVICE_DEMUX: Digital TV demux. + * @DVB_DEVICE_DVR: Digital TV digital video record (DVR). + * @DVB_DEVICE_CA: Digital TV Conditional Access (CA). + * @DVB_DEVICE_NET: Digital TV network. + * + * @DVB_DEVICE_VIDEO: Digital TV video decoder. + * Deprecated. Used only on av7110-av. + * @DVB_DEVICE_AUDIO: Digital TV audio decoder. + * Deprecated. Used only on av7110-av. + * @DVB_DEVICE_OSD: Digital TV On Screen Display (OSD). + * Deprecated. Used only on av7110. + */ +enum dvb_device_type { + DVB_DEVICE_SEC, + DVB_DEVICE_FRONTEND, + DVB_DEVICE_DEMUX, + DVB_DEVICE_DVR, + DVB_DEVICE_CA, + DVB_DEVICE_NET, + + DVB_DEVICE_VIDEO, + DVB_DEVICE_AUDIO, + DVB_DEVICE_OSD, +}; + +#define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \ + static short adapter_nr[] = \ + {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \ + module_param_array(adapter_nr, short, NULL, 0444); \ + MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers") + +struct dvb_frontend; + +/** + * struct dvb_adapter - represents a Digital TV adapter using Linux DVB API + * + * @num: Number of the adapter + * @list_head: List with the DVB adapters + * @device_list: List with the DVB devices + * @name: Name of the adapter + * @proposed_mac: proposed MAC address for the adapter + * @priv: private data + * @device: pointer to struct device + * @module: pointer to struct module + * @mfe_shared: mfe shared: indicates mutually exclusive frontends + * Thie usage of this flag is currently deprecated + * @mfe_dvbdev: Frontend device in use, in the case of MFE + * @mfe_lock: Lock to prevent using the other frontends when MFE is + * used. + * @mdev: pointer to struct media_device, used when the media + * controller is used. + * @conn: RF connector. Used only if the device has no separate + * tuner. + * @conn_pads: pointer to struct media_pad associated with @conn; + */ +struct dvb_adapter { + int num; + struct list_head list_head; + struct list_head device_list; + const char *name; + u8 proposed_mac [6]; + void* priv; + + struct device *device; + + struct module *module; + + int mfe_shared; /* indicates mutually exclusive frontends */ + struct dvb_device *mfe_dvbdev; /* frontend device in use */ + struct mutex mfe_lock; /* access lock for thread creation */ + +#if defined(CONFIG_MEDIA_CONTROLLER_DVB) + struct media_device *mdev; + struct media_entity *conn; + struct media_pad *conn_pads; +#endif +}; + +/** + * struct dvb_device - represents a DVB device node + * + * @list_head: List head with all DVB devices + * @fops: pointer to struct file_operations + * @adapter: pointer to the adapter that holds this device node + * @type: type of the device, as defined by &enum dvb_device_type. + * @minor: devnode minor number. Major number is always DVB_MAJOR. + * @id: device ID number, inside the adapter + * @readers: Initialized by the caller. Each call to open() in Read Only mode + * decreases this counter by one. + * @writers: Initialized by the caller. Each call to open() in Read/Write + * mode decreases this counter by one. + * @users: Initialized by the caller. Each call to open() in any mode + * decreases this counter by one. + * @wait_queue: wait queue, used to wait for certain events inside one of + * the DVB API callers + * @kernel_ioctl: callback function used to handle ioctl calls from userspace. + * @name: Name to be used for the device at the Media Controller + * @entity: pointer to struct media_entity associated with the device node + * @pads: pointer to struct media_pad associated with @entity; + * @priv: private data + * @intf_devnode: Pointer to media_intf_devnode. Used by the dvbdev core to + * store the MC device node interface + * @tsout_num_entities: Number of Transport Stream output entities + * @tsout_entity: array with MC entities associated to each TS output node + * @tsout_pads: array with the source pads for each @tsout_entity + * + * This structure is used by the DVB core (frontend, CA, net, demux) in + * order to create the device nodes. Usually, driver should not initialize + * this struct diretly. + */ +struct dvb_device { + struct list_head list_head; + const struct file_operations *fops; + struct dvb_adapter *adapter; + enum dvb_device_type type; + int minor; + u32 id; + + /* in theory, 'users' can vanish now, + but I don't want to change too much now... */ + int readers; + int writers; + int users; + + wait_queue_head_t wait_queue; + /* don't really need those !? -- FIXME: use video_usercopy */ + int (*kernel_ioctl)(struct file *file, unsigned int cmd, void *arg); + + /* Needed for media controller register/unregister */ +#if defined(CONFIG_MEDIA_CONTROLLER_DVB) + const char *name; + + /* Allocated and filled inside dvbdev.c */ + struct media_intf_devnode *intf_devnode; + + unsigned tsout_num_entities; + struct media_entity *entity, *tsout_entity; + struct media_pad *pads, *tsout_pads; +#endif + + void *priv; +}; + +/** + * dvb_register_adapter - Registers a new DVB adapter + * + * @adap: pointer to struct dvb_adapter + * @name: Adapter's name + * @module: initialized with THIS_MODULE at the caller + * @device: pointer to struct device that corresponds to the device driver + * @adapter_nums: Array with a list of the numbers for @dvb_register_adapter; + * to select among them. Typically, initialized with: + * DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nums) + */ +int dvb_register_adapter(struct dvb_adapter *adap, const char *name, + struct module *module, struct device *device, + short *adapter_nums); + +/** + * dvb_unregister_adapter - Unregisters a DVB adapter + * + * @adap: pointer to struct dvb_adapter + */ +int dvb_unregister_adapter(struct dvb_adapter *adap); + +/** + * dvb_register_device - Registers a new DVB device + * + * @adap: pointer to struct dvb_adapter + * @pdvbdev: pointer to the place where the new struct dvb_device will be + * stored + * @template: Template used to create &pdvbdev; + * @priv: private data + * @type: type of the device, as defined by &enum dvb_device_type. + * @demux_sink_pads: Number of demux outputs, to be used to create the TS + * outputs via the Media Controller. + */ +int dvb_register_device(struct dvb_adapter *adap, + struct dvb_device **pdvbdev, + const struct dvb_device *template, + void *priv, + enum dvb_device_type type, + int demux_sink_pads); + +/** + * dvb_remove_device - Remove a registered DVB device + * + * This does not free memory. To do that, call dvb_free_device(). + * + * @dvbdev: pointer to struct dvb_device + */ +void dvb_remove_device(struct dvb_device *dvbdev); + +/** + * dvb_free_device - Free memory occupied by a DVB device. + * + * Call dvb_unregister_device() before calling this function. + * + * @dvbdev: pointer to struct dvb_device + */ +void dvb_free_device(struct dvb_device *dvbdev); + +/** + * dvb_unregister_device - Unregisters a DVB device + * + * This is a combination of dvb_remove_device() and dvb_free_device(). + * Using this function is usually a mistake, and is often an indicator + * for a use-after-free bug (when a userspace process keeps a file + * handle to a detached device). + * + * @dvbdev: pointer to struct dvb_device + */ +void dvb_unregister_device(struct dvb_device *dvbdev); + +#ifdef CONFIG_MEDIA_CONTROLLER_DVB +/** + * dvb_create_media_graph - Creates media graph for the Digital TV part of the + * device. + * + * @adap: pointer to &struct dvb_adapter + * @create_rf_connector: if true, it creates the RF connector too + * + * This function checks all DVB-related functions at the media controller + * entities and creates the needed links for the media graph. It is + * capable of working with multiple tuners or multiple frontends, but it + * won't create links if the device has multiple tuners and multiple frontends + * or if the device has multiple muxes. In such case, the caller driver should + * manually create the remaining links. + */ +__must_check int dvb_create_media_graph(struct dvb_adapter *adap, + bool create_rf_connector); + +/** + * dvb_register_media_controller - registers a media controller at DVB adapter + * + * @adap: pointer to &struct dvb_adapter + * @mdev: pointer to &struct media_device + */ +static inline void dvb_register_media_controller(struct dvb_adapter *adap, + struct media_device *mdev) +{ + adap->mdev = mdev; +} + +/** + * dvb_get_media_controller - gets the associated media controller + * + * @adap: pointer to &struct dvb_adapter + */ +static inline struct media_device +*dvb_get_media_controller(struct dvb_adapter *adap) +{ + return adap->mdev; +} +#else +static inline +int dvb_create_media_graph(struct dvb_adapter *adap, + bool create_rf_connector) +{ + return 0; +}; +#define dvb_register_media_controller(a, b) {} +#define dvb_get_media_controller(a) NULL +#endif + +/** + * dvb_generic_open - Digital TV open function, used by DVB devices + * + * @inode: pointer to &struct inode. + * @file: pointer to &struct file. + * + * Checks if a DVB devnode is still valid, and if the permissions are + * OK and increment negative use count. + */ +int dvb_generic_open(struct inode *inode, struct file *file); + +/** + * dvb_generic_close - Digital TV close function, used by DVB devices + * + * @inode: pointer to &struct inode. + * @file: pointer to &struct file. + * + * Checks if a DVB devnode is still valid, and if the permissions are + * OK and decrement negative use count. + */ +int dvb_generic_release(struct inode *inode, struct file *file); + +/** + * dvb_generic_ioctl - Digital TV close function, used by DVB devices + * + * @file: pointer to &struct file. + * @cmd: Ioctl name. + * @arg: Ioctl argument. + * + * Checks if a DVB devnode and struct dvbdev.kernel_ioctl is still valid. + * If so, calls dvb_usercopy(). + */ +long dvb_generic_ioctl(struct file *file, + unsigned int cmd, unsigned long arg); + +/** + * dvb_usercopy - copies data from/to userspace memory when an ioctl is + * issued. + * + * @file: Pointer to struct &file. + * @cmd: Ioctl name. + * @arg: Ioctl argument. + * @func: function that will actually handle the ioctl + * + * Ancillary function that uses ioctl direction and size to copy from + * userspace. Then, it calls @func, and, if needed, data is copied back + * to userspace. + */ +int dvb_usercopy(struct file *file, unsigned int cmd, unsigned long arg, + int (*func)(struct file *file, unsigned int cmd, void *arg)); + +/** generic DVB attach function. */ +#ifdef CONFIG_MEDIA_ATTACH + +/** + * dvb_attach - attaches a DVB frontend into the DVB core. + * + * @FUNCTION: function on a frontend module to be called. + * @ARGS...: @FUNCTION arguments. + * + * This ancillary function loads a frontend module in runtime and runs + * the @FUNCTION function there, with @ARGS. + * As it increments symbol usage cont, at unregister, dvb_detach() + * should be called. + */ +#define dvb_attach(FUNCTION, ARGS...) ({ \ + void *__r = NULL; \ + typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ + if (__a) { \ + __r = (void *) __a(ARGS); \ + if (__r == NULL) \ + symbol_put(FUNCTION); \ + } else { \ + printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \ + } \ + __r; \ +}) + +/** + * dvb_detach - detaches a DVB frontend loaded via dvb_attach() + * + * @FUNC: attach function + * + * Decrements usage count for a function previously called via dvb_attach(). + */ + +#define dvb_detach(FUNC) symbol_put_addr(FUNC) + +#else +#define dvb_attach(FUNCTION, ARGS...) ({ \ + FUNCTION(ARGS); \ +}) + +#define dvb_detach(FUNC) {} + +#endif + +#endif /* #ifndef _DVBDEV_H_ */ diff --git a/include/media/videobuf-dvb.h b/include/media/videobuf-dvb.h index a14ac7711c92..c9c81990a56c 100644 --- a/include/media/videobuf-dvb.h +++ b/include/media/videobuf-dvb.h @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifndef _VIDEOBUF_DVB_H_ #define _VIDEOBUF_DVB_H_ diff --git a/include/media/videobuf2-dvb.h b/include/media/videobuf2-dvb.h index 5a31faa24f1a..8605366ec87c 100644 --- a/include/media/videobuf2-dvb.h +++ b/include/media/videobuf2-dvb.h @@ -2,12 +2,11 @@ #ifndef _VIDEOBUF2_DVB_H_ #define _VIDEOBUF2_DVB_H_ -#include -#include -#include -#include -#include - +#include +#include +#include +#include +#include #include /* We don't actually need to include media-device.h here */ -- cgit From f6e8fe94da9964380036969f86bd3a7c6bdd8fe9 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Fri, 8 Sep 2017 09:47:26 -0400 Subject: media: i2c: as3645a: Remove driver Remove the V4L2 AS3645A sub-device driver in favour of the LED flash class driver for the same hardware, drivers/leds/leds-as3645a.c. The latter uses the V4L2 flash LED class framework to provide V4L2 sub-device interface. Signed-off-by: Sakari Ailus Acked-by: Pavel Machek Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- include/media/i2c/as3645a.h | 66 --------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 include/media/i2c/as3645a.h (limited to 'include/media') diff --git a/include/media/i2c/as3645a.h b/include/media/i2c/as3645a.h deleted file mode 100644 index fffd4b563f5a..000000000000 --- a/include/media/i2c/as3645a.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * include/media/i2c/as3645a.h - * - * Copyright (C) 2008-2011 Nokia Corporation - * - * Contact: Laurent Pinchart - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#ifndef __AS3645A_H__ -#define __AS3645A_H__ - -#include - -#define AS3645A_NAME "as3645a" -#define AS3645A_I2C_ADDR (0x60 >> 1) /* W:0x60, R:0x61 */ - -#define AS3645A_FLASH_TIMEOUT_MIN 100000 /* us */ -#define AS3645A_FLASH_TIMEOUT_MAX 850000 -#define AS3645A_FLASH_TIMEOUT_STEP 50000 - -#define AS3645A_FLASH_INTENSITY_MIN 200 /* mA */ -#define AS3645A_FLASH_INTENSITY_MAX_1LED 500 -#define AS3645A_FLASH_INTENSITY_MAX_2LEDS 400 -#define AS3645A_FLASH_INTENSITY_STEP 20 - -#define AS3645A_TORCH_INTENSITY_MIN 20 /* mA */ -#define AS3645A_TORCH_INTENSITY_MAX 160 -#define AS3645A_TORCH_INTENSITY_STEP 20 - -#define AS3645A_INDICATOR_INTENSITY_MIN 0 /* uA */ -#define AS3645A_INDICATOR_INTENSITY_MAX 10000 -#define AS3645A_INDICATOR_INTENSITY_STEP 2500 - -/* - * as3645a_platform_data - Flash controller platform data - * @set_power: Set power callback - * @vref: VREF offset (0=0V, 1=+0.3V, 2=-0.3V, 3=+0.6V) - * @peak: Inductor peak current limit (0=1.25A, 1=1.5A, 2=1.75A, 3=2.0A) - * @ext_strobe: True if external flash strobe can be used - * @flash_max_current: Max flash current (mA, <= AS3645A_FLASH_INTENSITY_MAX) - * @torch_max_current: Max torch current (mA, >= AS3645A_TORCH_INTENSITY_MAX) - * @timeout_max: Max flash timeout (us, <= AS3645A_FLASH_TIMEOUT_MAX) - */ -struct as3645a_platform_data { - int (*set_power)(struct v4l2_subdev *subdev, int on); - unsigned int vref; - unsigned int peak; - bool ext_strobe; - - /* Flash and torch currents and timeout limits */ - unsigned int flash_max_current; - unsigned int torch_max_current; - unsigned int timeout_max; -}; - -#endif /* __AS3645A_H__ */ -- cgit From d651ff916ead5608753f6493dfa3d99ef6e01ab7 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 22 Sep 2017 12:31:02 -0400 Subject: media: v4l2-device.h: document helper macros There are several macros that aren't documented using kernel-docs markups. Document them. While here, add cross-references to structs on this file. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-device.h | 246 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 211 insertions(+), 35 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h index 8ffa94009d1a..0c9e4da55499 100644 --- a/include/media/v4l2-device.h +++ b/include/media/v4l2-device.h @@ -38,7 +38,7 @@ struct v4l2_ctrl_handler; * @lock: lock this struct; can be used by the driver as well * if this struct is embedded into a larger struct. * @name: unique device name, by default the driver name + bus ID - * @notify: notify callback called by some sub-devices. + * @notify: notify operation called by some sub-devices. * @ctrl_handler: The control handler. May be %NULL. * @prio: Device's priority state * @ref: Keep track of the references to this struct. @@ -56,7 +56,6 @@ struct v4l2_ctrl_handler; * #) @dev->driver_data points to this struct. * #) @dev might be %NULL if there is no parent device */ - struct v4l2_device { struct device *dev; #if defined(CONFIG_MEDIA_CONTROLLER) @@ -166,7 +165,7 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev); * v4l2_device_register_subdev - Registers a subdev with a v4l2 device. * * @v4l2_dev: pointer to struct &v4l2_device - * @sd: pointer to struct &v4l2_subdev + * @sd: pointer to &struct v4l2_subdev * * While registered, the subdev module is marked as in-use. * @@ -179,7 +178,7 @@ int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, /** * v4l2_device_unregister_subdev - Unregisters a subdev with a v4l2 device. * - * @sd: pointer to struct &v4l2_subdev + * @sd: pointer to &struct v4l2_subdev * * .. note :: * @@ -201,7 +200,7 @@ v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev); /** * v4l2_subdev_notify - Sends a notification to v4l2_device. * - * @sd: pointer to struct &v4l2_subdev + * @sd: pointer to &struct v4l2_subdev * @notification: type of notification. Please notice that the notification * type is driver-specific. * @arg: arguments for the notification. Those are specific to each @@ -214,13 +213,43 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, sd->v4l2_dev->notify(sd, notification, arg); } -/* Iterate over all subdevs. */ +/* Helper macros to iterate over all subdevs. */ + +/** + * v4l2_device_for_each_subdev - Helper macro that interates over all + * sub-devices of a given &v4l2_device. + * + * @sd: pointer that will be filled by the macro with all + * &struct v4l2_subdev pointer used as an iterator by the loop. + * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. + * + * This macro iterates over all sub-devices owned by the @v4l2_dev device. + * It acts as a for loop iterator and executes the next statement with + * the @sd variable pointing to each sub-device in turn. + */ #define v4l2_device_for_each_subdev(sd, v4l2_dev) \ list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) -/* Call the specified callback for all subdevs matching the condition. - Ignore any errors. Note that you cannot add or delete a subdev - while walking the subdevs list. */ +/** + * __v4l2_device_call_subdevs_p - Calls the specified operation for + * all subdevs matching the condition. + * + * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. + * @sd: pointer that will be filled by the macro with all + * &struct v4l2_subdev pointer used as an iterator by the loop. + * @cond: condition to be match + * @o: name of the element at &struct v4l2_subdev_ops that contains @f. + * Each element there groups a set of operations functions. + * @f: operation function that will be called if @cond matches. + * The operation functions are defined in groups, according to + * each element at &struct v4l2_subdev_ops. + * @args...: arguments for @f. + * + * Ignore any errors. + * + * Note: subdevs cannot be added or deleted while walking + * the subdevs list. + */ #define __v4l2_device_call_subdevs_p(v4l2_dev, sd, cond, o, f, args...) \ do { \ list_for_each_entry((sd), &(v4l2_dev)->subdevs, list) \ @@ -228,6 +257,24 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, (sd)->ops->o->f((sd) , ##args); \ } while (0) +/** + * __v4l2_device_call_subdevs - Calls the specified operation for + * all subdevs matching the condition. + * + * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. + * @cond: condition to be match + * @o: name of the element at &struct v4l2_subdev_ops that contains @f. + * Each element there groups a set of operations functions. + * @f: operation function that will be called if @cond matches. + * The operation functions are defined in groups, according to + * each element at &struct v4l2_subdev_ops. + * @args...: arguments for @f. + * + * Ignore any errors. + * + * Note: subdevs cannot be added or deleted while walking + * the subdevs list. + */ #define __v4l2_device_call_subdevs(v4l2_dev, cond, o, f, args...) \ do { \ struct v4l2_subdev *__sd; \ @@ -236,10 +283,30 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, f , ##args); \ } while (0) -/* Call the specified callback for all subdevs matching the condition. - If the callback returns an error other than 0 or -ENOIOCTLCMD, then - return with that error code. Note that you cannot add or delete a - subdev while walking the subdevs list. */ +/** + * __v4l2_device_call_subdevs_until_err_p - Calls the specified operation for + * all subdevs matching the condition. + * + * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. + * @sd: pointer that will be filled by the macro with all + * &struct v4l2_subdev sub-devices associated with @v4l2_dev. + * @cond: condition to be match + * @o: name of the element at &struct v4l2_subdev_ops that contains @f. + * Each element there groups a set of operations functions. + * @f: operation function that will be called if @cond matches. + * The operation functions are defined in groups, according to + * each element at &struct v4l2_subdev_ops. + * @args...: arguments for @f. + * + * Return: + * + * If the operation returns an error other than 0 or ``-ENOIOCTLCMD`` + * for any subdevice, then abort and return with that error code, zero + * otherwise. + * + * Note: subdevs cannot be added or deleted while walking + * the subdevs list. + */ #define __v4l2_device_call_subdevs_until_err_p(v4l2_dev, sd, cond, o, f, args...) \ ({ \ long __err = 0; \ @@ -253,6 +320,28 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, (__err == -ENOIOCTLCMD) ? 0 : __err; \ }) +/** + * __v4l2_device_call_subdevs_until_err - Calls the specified operation for + * all subdevs matching the condition. + * + * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. + * @cond: condition to be match + * @o: name of the element at &struct v4l2_subdev_ops that contains @f. + * Each element there groups a set of operations functions. + * @f: operation function that will be called if @cond matches. + * The operation functions are defined in groups, according to + * each element at &struct v4l2_subdev_ops. + * @args...: arguments for @f. + * + * Return: + * + * If the operation returns an error other than 0 or ``-ENOIOCTLCMD`` + * for any subdevice, then abort and return with that error code, + * zero otherwise. + * + * Note: subdevs cannot be added or deleted while walking + * the subdevs list. + */ #define __v4l2_device_call_subdevs_until_err(v4l2_dev, cond, o, f, args...) \ ({ \ struct v4l2_subdev *__sd; \ @@ -260,9 +349,26 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, f , ##args); \ }) -/* Call the specified callback for all subdevs matching grp_id (if 0, then - match them all). Ignore any errors. Note that you cannot add or delete - a subdev while walking the subdevs list. */ +/** + * v4l2_device_call_all - Calls the specified operation for + * all subdevs matching the &v4l2_subdev.grp_id, as assigned + * by the bridge driver. + * + * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. + * @grpid: &struct v4l2_subdev->grp_id group ID to match. + * Use 0 to match them all. + * @o: name of the element at &struct v4l2_subdev_ops that contains @f. + * Each element there groups a set of operations functions. + * @f: operation function that will be called if @cond matches. + * The operation functions are defined in groups, according to + * each element at &struct v4l2_subdev_ops. + * @args...: arguments for @f. + * + * Ignore any errors. + * + * Note: subdevs cannot be added or deleted while walking + * the subdevs list. + */ #define v4l2_device_call_all(v4l2_dev, grpid, o, f, args...) \ do { \ struct v4l2_subdev *__sd; \ @@ -272,10 +378,30 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, ##args); \ } while (0) -/* Call the specified callback for all subdevs matching grp_id (if 0, then - match them all). If the callback returns an error other than 0 or - -ENOIOCTLCMD, then return with that error code. Note that you cannot - add or delete a subdev while walking the subdevs list. */ +/** + * v4l2_device_call_until_err - Calls the specified operation for + * all subdevs matching the &v4l2_subdev.grp_id, as assigned + * by the bridge driver, until an error occurs. + * + * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. + * @grpid: &struct v4l2_subdev->grp_id group ID to match. + * Use 0 to match them all. + * @o: name of the element at &struct v4l2_subdev_ops that contains @f. + * Each element there groups a set of operations functions. + * @f: operation function that will be called if @cond matches. + * The operation functions are defined in groups, according to + * each element at &struct v4l2_subdev_ops. + * @args...: arguments for @f. + * + * Return: + * + * If the operation returns an error other than 0 or ``-ENOIOCTLCMD`` + * for any subdevice, then abort and return with that error code, + * zero otherwise. + * + * Note: subdevs cannot be added or deleted while walking + * the subdevs list. + */ #define v4l2_device_call_until_err(v4l2_dev, grpid, o, f, args...) \ ({ \ struct v4l2_subdev *__sd; \ @@ -284,10 +410,24 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, ##args); \ }) -/* - * Call the specified callback for all subdevs where grp_id & grpmsk != 0 - * (if grpmsk == `0, then match them all). Ignore any errors. Note that you - * cannot add or delete a subdev while walking the subdevs list. +/** + * v4l2_device_mask_call_all - Calls the specified operation for + * all subdevices where a group ID matches a specified bitmask. + * + * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. + * @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id + * group ID to be matched. Use 0 to match them all. + * @o: name of the element at &struct v4l2_subdev_ops that contains @f. + * Each element there groups a set of operations functions. + * @f: operation function that will be called if @cond matches. + * The operation functions are defined in groups, according to + * each element at &struct v4l2_subdev_ops. + * @args...: arguments for @f. + * + * Ignore any errors. + * + * Note: subdevs cannot be added or deleted while walking + * the subdevs list. */ #define v4l2_device_mask_call_all(v4l2_dev, grpmsk, o, f, args...) \ do { \ @@ -298,11 +438,28 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, ##args); \ } while (0) -/* - * Call the specified callback for all subdevs where grp_id & grpmsk != 0 - * (if grpmsk == 0, then match them all). If the callback returns an error - * other than 0 or %-ENOIOCTLCMD, then return with that error code. Note that - * you cannot add or delete a subdev while walking the subdevs list. +/** + * v4l2_device_mask_call_until_err - Calls the specified operation for + * all subdevices where a group ID matches a specified bitmask. + * + * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. + * @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id + * group ID to be matched. Use 0 to match them all. + * @o: name of the element at &struct v4l2_subdev_ops that contains @f. + * Each element there groups a set of operations functions. + * @f: operation function that will be called if @cond matches. + * The operation functions are defined in groups, according to + * each element at &struct v4l2_subdev_ops. + * @args...: arguments for @f. + * + * Return: + * + * If the operation returns an error other than 0 or ``-ENOIOCTLCMD`` + * for any subdevice, then abort and return with that error code, + * zero otherwise. + * + * Note: subdevs cannot be added or deleted while walking + * the subdevs list. */ #define v4l2_device_mask_call_until_err(v4l2_dev, grpmsk, o, f, args...) \ ({ \ @@ -312,9 +469,19 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, ##args); \ }) -/* - * Does any subdev with matching grpid (or all if grpid == 0) has the given - * op? + +/** + * v4l2_device_has_op - checks if any subdev with matching grpid has a + * given ops. + * + * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. + * @grpid: &struct v4l2_subdev->grp_id group ID to match. + * Use 0 to match them all. + * @o: name of the element at &struct v4l2_subdev_ops that contains @f. + * Each element there groups a set of operations functions. + * @f: operation function that will be called if @cond matches. + * The operation functions are defined in groups, according to + * each element at &struct v4l2_subdev_ops. */ #define v4l2_device_has_op(v4l2_dev, grpid, o, f) \ ({ \ @@ -331,9 +498,18 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, __result; \ }) -/* - * Does any subdev with matching grpmsk (or all if grpmsk == 0) has the given - * op? +/** + * v4l2_device_mask_has_op - checks if any subdev with matching group + * mask has a given ops. + * + * @v4l2_dev: &struct v4l2_device owning the sub-devices to iterate over. + * @grpmsk: bitmask to be checked against &struct v4l2_subdev->grp_id + * group ID to be matched. Use 0 to match them all. + * @o: name of the element at &struct v4l2_subdev_ops that contains @f. + * Each element there groups a set of operations functions. + * @f: operation function that will be called if @cond matches. + * The operation functions are defined in groups, according to + * each element at &struct v4l2_subdev_ops. */ #define v4l2_device_mask_has_op(v4l2_dev, grpmsk, o, f) \ ({ \ -- cgit From 4e48afecd5ee3a394d228349fc1c33982e9fb557 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 27 Sep 2017 10:12:00 -0400 Subject: media: v4l2-async: simplify v4l2_async_subdev structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The V4L2_ASYNC_MATCH_FWNODE match criteria requires just one struct to be filled (struct fwnode_handle). The V4L2_ASYNC_MATCH_DEVNAME match criteria requires just a device name. So, it doesn't make sense to enclose those into structs, as the criteria can go directly into the union. That makes easier to document it, as we don't need to document weird senseless structs. At drivers, this makes even clearer about the match criteria. Acked-by: Sylwester Nawrocki Acked-by: Benoit Parrot Acked-by: Alexandre Belloni Acked-by: Sakari Ailus Acked-by: Philipp Zabel Acked-by: Hyun Kwon Acked-by: Niklas Söderlund Acked-by: Lad, Prabhakar Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-async.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index 6152434cbe82..a010af5134b2 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -58,12 +58,8 @@ enum v4l2_async_match_type { struct v4l2_async_subdev { enum v4l2_async_match_type match_type; union { - struct { - struct fwnode_handle *fwnode; - } fwnode; - struct { - const char *name; - } device_name; + struct fwnode_handle *fwnode; + const char *device_name; struct { int adapter_id; unsigned short address; -- cgit From eb0f73ba12305842153758fdee2a75776724a528 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 27 Sep 2017 11:43:00 -0400 Subject: media: v4l2-async: better describe match union at async match struct Now that kernel-doc handles nested unions, better document the match union at struct v4l2_async_subdev. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-async.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include/media') diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index a010af5134b2..96e19246b934 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -48,6 +48,31 @@ enum v4l2_async_match_type { * * @match_type: type of match that will be used * @match: union of per-bus type matching data sets + * @match.fwnode: + * pointer to &struct fwnode_handle to be matched. + * Used if @match_type is %V4L2_ASYNC_MATCH_FWNODE. + * @match.device_name: + * string containing the device name to be matched. + * Used if @match_type is %V4L2_ASYNC_MATCH_DEVNAME. + * @match.i2c: embedded struct with I2C parameters to be matched. + * Both @match.i2c.adapter_id and @match.i2c.address + * should be matched. + * Used if @match_type is %V4L2_ASYNC_MATCH_I2C. + * @match.i2c.adapter_id: + * I2C adapter ID to be matched. + * Used if @match_type is %V4L2_ASYNC_MATCH_I2C. + * @match.i2c.address: + * I2C address to be matched. + * Used if @match_type is %V4L2_ASYNC_MATCH_I2C. + * @match.custom: + * Driver-specific match criteria. + * Used if @match_type is %V4L2_ASYNC_MATCH_CUSTOM. + * @match.custom.match: + * Driver-specific match function to be used if + * %V4L2_ASYNC_MATCH_CUSTOM. + * @match.custom.priv: + * Driver-specific private struct with match parameters + * to be used if %V4L2_ASYNC_MATCH_CUSTOM. * @list: used to link struct v4l2_async_subdev objects, waiting to be * probed, to a notifier->waiting list * -- cgit From 15128beef1ce3d48565f44756ff4a2077ac97a01 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 29 Dec 2017 07:54:12 -0500 Subject: media: dvb_vb2: get rid of DVB_BUF_TYPE_OUTPUT This is currently unused. So, get rid of it. Signed-off-by: Mauro Carvalho Chehab --- include/media/dvb_vb2.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/media') diff --git a/include/media/dvb_vb2.h b/include/media/dvb_vb2.h index 7a529844c5e1..ef4a802f7435 100644 --- a/include/media/dvb_vb2.h +++ b/include/media/dvb_vb2.h @@ -24,7 +24,6 @@ enum dvb_buf_type { DVB_BUF_TYPE_CAPTURE = 1, - DVB_BUF_TYPE_OUTPUT = 2, }; #define DVB_VB2_STATE_NONE (0x0) -- cgit From 9f577d6db5bf7d76fb9e26894a92fcb4ecb4c832 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 29 Dec 2017 08:23:41 -0500 Subject: media: dvb kAPI docs: document dvb_vb2.h Document the data structures and functions inside this kAPI header. Signed-off-by: Mauro Carvalho Chehab --- include/media/dmxdev.h | 2 + include/media/dvb_vb2.h | 183 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 179 insertions(+), 6 deletions(-) (limited to 'include/media') diff --git a/include/media/dmxdev.h b/include/media/dmxdev.h index d5bef0da2e6e..2f5cb2c7b6a7 100644 --- a/include/media/dmxdev.h +++ b/include/media/dmxdev.h @@ -112,6 +112,7 @@ struct dmxdev_feed { * @state: state of the dmxdev filter, as defined by &enum dmxdev_state. * @dev: pointer to &struct dmxdev. * @buffer: an embedded &struct dvb_ringbuffer buffer. + * @vb2_ctx: control struct for VB2 handler * @mutex: protects the access to &struct dmxdev_filter. * @timer: &struct timer_list embedded timer, used to check for * feed timeouts. @@ -165,6 +166,7 @@ struct dmxdev_filter { * @exit: flag to indicate that the demux is being released. * @dvr_orig_fe: pointer to &struct dmx_frontend. * @dvr_buffer: embedded &struct dvb_ringbuffer for DVB output. + * @dvr_vb2_ctx: control struct for VB2 handler * @mutex: protects the usage of this structure. * @lock: protects access to &dmxdev->filter->data. */ diff --git a/include/media/dvb_vb2.h b/include/media/dvb_vb2.h index ef4a802f7435..5431e5a7e140 100644 --- a/include/media/dvb_vb2.h +++ b/include/media/dvb_vb2.h @@ -22,22 +22,72 @@ #include #include +/** + * enum dvb_buf_type - types of Digital TV memory-mapped buffers + * + * @DVB_BUF_TYPE_CAPTURE: buffer is filled by the Kernel, + * with a received Digital TV stream + */ enum dvb_buf_type { DVB_BUF_TYPE_CAPTURE = 1, }; -#define DVB_VB2_STATE_NONE (0x0) -#define DVB_VB2_STATE_INIT (0x1) -#define DVB_VB2_STATE_REQBUFS (0x2) -#define DVB_VB2_STATE_STREAMON (0x4) +/** + * enum dvb_vb2_states - states to control VB2 state machine + * @DVB_VB2_STATE_NONE: + * VB2 engine not initialized yet, init failed or VB2 was released. + * @DVB_VB2_STATE_INIT: + * VB2 engine initialized. + * @DVB_VB2_STATE_REQBUFS: + * Buffers were requested + * @DVB_VB2_STATE_STREAMON: + * VB2 is streaming. Callers should not check it directly. Instead, + * they should use dvb_vb2_is_streaming(). + * + * Note: + * + * Callers should not touch at the state machine directly. This + * is handled inside dvb_vb2.c. + */ +enum dvb_vb2_states { + DVB_VB2_STATE_NONE = 0x0, + DVB_VB2_STATE_INIT = 0x1, + DVB_VB2_STATE_REQBUFS = 0x2, + DVB_VB2_STATE_STREAMON = 0x4, +}; #define DVB_VB2_NAME_MAX (20) +/** + * struct dvb_buffer - video buffer information for v4l2. + * + * @vb: embedded struct &vb2_buffer. + * @list: list of &struct dvb_buffer. + */ struct dvb_buffer { struct vb2_buffer vb; struct list_head list; }; +/** + * struct dvb_vb2_ctx - control struct for VB2 handler + * @vb_q: pointer to &struct vb2_queue with videobuf2 queue. + * @mutex: mutex to serialize vb2 operations. Used by + * vb2 core %wait_prepare and %wait_finish operations. + * @slock: spin lock used to protect buffer filling at dvb_vb2.c. + * @dvb_q: List of buffers that are not filled yet. + * @buf: Pointer to the buffer that are currently being filled. + * @offset: index to the next position at the @buf to be filled. + * @remain: How many bytes are left to be filled at @buf. + * @state: bitmask of buffer states as defined by &enum dvb_vb2_states. + * @buf_siz: size of each VB2 buffer. + * @buf_cnt: number of VB2 buffers. + * @nonblocking: + * If different than zero, device is operating on non-blocking + * mode. + * @name: name of the device type. Currently, it can either be + * "dvr" or "demux_filter". + */ struct dvb_vb2_ctx { struct vb2_queue vb_q; struct mutex mutex; @@ -53,8 +103,6 @@ struct dvb_vb2_ctx { char name[DVB_VB2_NAME_MAX + 1]; }; -int dvb_vb2_stream_on(struct dvb_vb2_ctx *ctx); -int dvb_vb2_stream_off(struct dvb_vb2_ctx *ctx); #ifndef DVB_MMAP static inline int dvb_vb2_init(struct dvb_vb2_ctx *ctx, const char *name, int non_blocking) @@ -75,21 +123,144 @@ static inline unsigned int dvb_vb2_poll(struct dvb_vb2_ctx *ctx, return 0; } #else +/** + * dvb_vb2_init - initializes VB2 handler + * + * @ctx: control struct for VB2 handler + * @name: name for the VB2 handler + * @non_blocking: + * if not zero, it means that the device is at non-blocking mode + */ int dvb_vb2_init(struct dvb_vb2_ctx *ctx, const char *name, int non_blocking); + +/** + * dvb_vb2_release - Releases the VB2 handler allocated resources and + * put @ctx at DVB_VB2_STATE_NONE state. + * @ctx: control struct for VB2 handler + */ int dvb_vb2_release(struct dvb_vb2_ctx *ctx); + +/** + * dvb_vb2_is_streaming - checks if the VB2 handler is streaming + * @ctx: control struct for VB2 handler + * + * Return: 0 if not streaming, 1 otherwise. + */ int dvb_vb2_is_streaming(struct dvb_vb2_ctx *ctx); + +/** + * dvb_vb2_fill_buffer - fills a VB2 buffer + * @ctx: control struct for VB2 handler + * @src: place where the data is stored + * @len: number of bytes to be copied from @src + */ int dvb_vb2_fill_buffer(struct dvb_vb2_ctx *ctx, const unsigned char *src, int len); + +/** + * dvb_vb2_poll - Wrapper to vb2_core_streamon() for Digital TV + * buffer handling. + * + * @ctx: control struct for VB2 handler + * @file: &struct file argument passed to the poll + * file operation handler. + * @wait: &poll_table wait argument passed to the poll + * file operation handler. + * + * Implements poll syscall() logic. + */ unsigned int dvb_vb2_poll(struct dvb_vb2_ctx *ctx, struct file *file, poll_table *wait); #endif +/** + * dvb_vb2_stream_on() - Wrapper to vb2_core_streamon() for Digital TV + * buffer handling. + * + * @ctx: control struct for VB2 handler + * + * Starts dvb streaming + */ +int dvb_vb2_stream_on(struct dvb_vb2_ctx *ctx); +/** + * dvb_vb2_stream_off() - Wrapper to vb2_core_streamoff() for Digital TV + * buffer handling. + * + * @ctx: control struct for VB2 handler + * + * Stops dvb streaming + */ +int dvb_vb2_stream_off(struct dvb_vb2_ctx *ctx); +/** + * dvb_vb2_reqbufs() - Wrapper to vb2_core_reqbufs() for Digital TV + * buffer handling. + * + * @ctx: control struct for VB2 handler + * @req: &struct dmx_requestbuffers passed from userspace in + * order to handle &DMX_REQBUFS. + * + * Initiate streaming by requesting a number of buffers. Also used to + * free previously requested buffers, is ``req->count`` is zero. + */ int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req); + +/** + * dvb_vb2_querybuf() - Wrapper to vb2_core_querybuf() for Digital TV + * buffer handling. + * + * @ctx: control struct for VB2 handler + * @b: &struct dmx_buffer passed from userspace in + * order to handle &DMX_QUERYBUF. + * + * + */ int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); + +/** + * dvb_vb2_expbuf() - Wrapper to vb2_core_expbuf() for Digital TV + * buffer handling. + * + * @ctx: control struct for VB2 handler + * @exp: &struct dmx_exportbuffer passed from userspace in + * order to handle &DMX_EXPBUF. + * + * Export a buffer as a file descriptor. + */ int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp); + +/** + * dvb_vb2_qbuf() - Wrapper to vb2_core_qbuf() for Digital TV buffer handling. + * + * @ctx: control struct for VB2 handler + * @b: &struct dmx_buffer passed from userspace in + * order to handle &DMX_QBUF. + * + * Queue a Digital TV buffer as requested by userspace + */ int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); + +/** + * dvb_vb2_dqbuf() - Wrapper to vb2_core_dqbuf() for Digital TV + * buffer handling. + * + * @ctx: control struct for VB2 handler + * @b: &struct dmx_buffer passed from userspace in + * order to handle &DMX_DQBUF. + * + * Dequeue a Digital TV buffer to the userspace + */ int dvb_vb2_dqbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); + +/** + * dvb_vb2_mmap() - Wrapper to vb2_mmap() for Digital TV buffer handling. + * + * @ctx: control struct for VB2 handler + * @vma: pointer to &struct vm_area_struct with the vma passed + * to the mmap file operation handler in the driver. + * + * map Digital TV video buffers into application address space. + */ int dvb_vb2_mmap(struct dvb_vb2_ctx *ctx, struct vm_area_struct *vma); #endif /* _DVB_VB2_H */ -- cgit From 4a3fad709bbc74c85fffff8903d17b5e35723365 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 4 Jan 2018 06:47:28 -0500 Subject: media: fix usage of whitespaces and on indentation On several places, whitespaces are being used for indentation, or even at the end of the line. Fix them. Signed-off-by: Mauro Carvalho Chehab --- include/media/dvb_frontend.h | 12 ++++++------ include/media/dvb_vb2.h | 2 +- include/media/dvbdev.h | 4 ++-- include/media/v4l2-async.h | 8 ++++---- include/media/v4l2-common.h | 4 ++-- include/media/v4l2-ctrls.h | 2 +- include/media/v4l2-dev.h | 16 ++++++++-------- include/media/v4l2-event.h | 2 +- include/media/v4l2-subdev.h | 8 ++++---- 9 files changed, 29 insertions(+), 29 deletions(-) (limited to 'include/media') diff --git a/include/media/dvb_frontend.h b/include/media/dvb_frontend.h index 0b40886fd7d3..331c8269c00e 100644 --- a/include/media/dvb_frontend.h +++ b/include/media/dvb_frontend.h @@ -99,10 +99,10 @@ struct dvb_tuner_info { * struct analog_parameters - Parameters to tune into an analog/radio channel * * @frequency: Frequency used by analog TV tuner (either in 62.5 kHz step, - * for TV, or 62.5 Hz for radio) + * for TV, or 62.5 Hz for radio) * @mode: Tuner mode, as defined on enum v4l2_tuner_type * @audmode: Audio mode as defined for the rxsubchans field at videodev2.h, - * e. g. V4L2_TUNER_MODE_* + * e. g. V4L2_TUNER_MODE_* * @std: TV standard bitmap as defined at videodev2.h, e. g. V4L2_STD_* * * Hybrid tuners should be supported by both V4L2 and DVB APIs. This @@ -205,7 +205,7 @@ enum dvbfe_search { * @get_frequency: get the actual tuned frequency * @get_bandwidth: get the bandwitdh used by the low pass filters * @get_if_frequency: get the Intermediate Frequency, in Hz. For baseband, - * should return 0. + * should return 0. * @get_status: returns the frontend lock status * @get_rf_strength: returns the RF signal strength. Used mostly to support * analog TV and radio. Digital TV should report, instead, @@ -364,7 +364,7 @@ struct dtv_frontend_properties; * implementing this callback only if DVBv3 API * compatibility is wanted. * @read_snr: legacy callback function to return the Signal/Noise - * rate. Newer drivers should provide such info via + * rate. Newer drivers should provide such info via * DVBv5 API, e. g. @set_frontend/@get_frontend, * implementing this callback only if DVBv3 API * compatibility is wanted. @@ -490,7 +490,7 @@ struct dvb_fe_events { * @fec_inner: Forward error correction inner Code Rate * @transmission_mode: Transmission Mode * @bandwidth_hz: Bandwidth, in Hz. A zero value means that userspace - * wants to autodetect. + * wants to autodetect. * @guard_interval: Guard Interval * @hierarchy: Hierarchy * @symbol_rate: Symbol Rate @@ -538,7 +538,7 @@ struct dvb_fe_events { * @lna: Power ON/OFF/AUTO the Linear Now-noise Amplifier (LNA) * @strength: DVBv5 API statistics: Signal Strength * @cnr: DVBv5 API statistics: Signal to Noise ratio of the - * (main) carrier + * (main) carrier * @pre_bit_error: DVBv5 API statistics: pre-Viterbi bit error count * @pre_bit_count: DVBv5 API statistics: pre-Viterbi bit count * @post_bit_error: DVBv5 API statistics: post-Viterbi bit error count diff --git a/include/media/dvb_vb2.h b/include/media/dvb_vb2.h index 5431e5a7e140..dda61af7c4cd 100644 --- a/include/media/dvb_vb2.h +++ b/include/media/dvb_vb2.h @@ -213,7 +213,7 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req); * @b: &struct dmx_buffer passed from userspace in * order to handle &DMX_QUERYBUF. * - * + * */ int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b); diff --git a/include/media/dvbdev.h b/include/media/dvbdev.h index bbc1c20c0529..554db879527f 100644 --- a/include/media/dvbdev.h +++ b/include/media/dvbdev.h @@ -193,7 +193,7 @@ struct dvb_device { * @module: initialized with THIS_MODULE at the caller * @device: pointer to struct device that corresponds to the device driver * @adapter_nums: Array with a list of the numbers for @dvb_register_adapter; - * to select among them. Typically, initialized with: + * to select among them. Typically, initialized with: * DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nums) */ int dvb_register_adapter(struct dvb_adapter *adap, const char *name, @@ -259,7 +259,7 @@ void dvb_unregister_device(struct dvb_device *dvbdev); #ifdef CONFIG_MEDIA_CONTROLLER_DVB /** * dvb_create_media_graph - Creates media graph for the Digital TV part of the - * device. + * device. * * @adap: pointer to &struct dvb_adapter * @create_rf_connector: if true, it creates the RF connector too diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index 96e19246b934..1592d323c577 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -28,7 +28,7 @@ struct v4l2_async_notifier; * in order to identify a match * * @V4L2_ASYNC_MATCH_CUSTOM: Match will use the logic provided by &struct - * v4l2_async_subdev.match ops + * v4l2_async_subdev.match ops * @V4L2_ASYNC_MATCH_DEVNAME: Match will use the device name * @V4L2_ASYNC_MATCH_I2C: Match will check for I2C adapter ID and address * @V4L2_ASYNC_MATCH_FWNODE: Match will use firmware node @@ -55,7 +55,7 @@ enum v4l2_async_match_type { * string containing the device name to be matched. * Used if @match_type is %V4L2_ASYNC_MATCH_DEVNAME. * @match.i2c: embedded struct with I2C parameters to be matched. - * Both @match.i2c.adapter_id and @match.i2c.address + * Both @match.i2c.adapter_id and @match.i2c.address * should be matched. * Used if @match_type is %V4L2_ASYNC_MATCH_I2C. * @match.i2c.adapter_id: @@ -188,7 +188,7 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier); /** * v4l2_async_register_subdev - registers a sub-device to the asynchronous - * subdevice framework + * subdevice framework * * @sd: pointer to &struct v4l2_subdev */ @@ -218,7 +218,7 @@ int __must_check v4l2_async_register_subdev_sensor_common( /** * v4l2_async_unregister_subdev - unregisters a sub-device to the asynchronous - * subdevice framework + * subdevice framework * * @sd: pointer to &struct v4l2_subdev */ diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index f420c45f7915..7fc0bc6b8007 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -127,7 +127,7 @@ struct v4l2_subdev_ops; * @client_type: name of the chip that's on the adapter. * @addr: I2C address. If zero, it will use @probe_addrs * @probe_addrs: array with a list of address. The last entry at such - * array should be %I2C_CLIENT_END. + * array should be %I2C_CLIENT_END. * * returns a &struct v4l2_subdev pointer. */ @@ -146,7 +146,7 @@ struct i2c_board_info; * @info: pointer to struct i2c_board_info used to replace the irq, * platform_data and addr arguments. * @probe_addrs: array with a list of address. The last entry at such - * array should be %I2C_CLIENT_END. + * array should be %I2C_CLIENT_END. * * returns a &struct v4l2_subdev pointer. */ diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 5ccf5019408a..5253b5471897 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -1146,7 +1146,7 @@ int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, /** * v4l2_ctrl_subdev_subscribe_event - Helper function to implement - * as a &struct v4l2_subdev_core_ops subscribe_event function + * as a &struct v4l2_subdev_core_ops subscribe_event function * that just subscribes control events. * * @sd: pointer to &struct v4l2_subdev diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index 88773a67a806..267fd2bed17b 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h @@ -66,7 +66,7 @@ struct v4l2_ctrl_handler; * enum v4l2_video_device_flags - Flags used by &struct video_device * * @V4L2_FL_REGISTERED: - * indicates that a &struct video_device is registered. + * indicates that a &struct video_device is registered. * Drivers can clear this flag if they want to block all future * device access. It is cleared by video_unregister_device. * @V4L2_FL_USES_V4L2_FH: @@ -198,7 +198,7 @@ struct v4l2_file_operations { /* * Newer version of video_device, handled by videodev2.c - * This version moves redundant code from video device code to + * This version moves redundant code from video device code to * the common handler */ @@ -317,7 +317,7 @@ struct video_device * @vdev: struct video_device to register * @type: type of device to register, as defined by &enum vfl_devnode_type * @nr: which device node number is desired: - * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) + * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) * @warn_if_nr_in_use: warn if the desired device node number * was already in use and another number was chosen instead. * @owner: module that owns the video device node @@ -351,13 +351,13 @@ int __must_check __video_register_device(struct video_device *vdev, * @vdev: struct video_device to register * @type: type of device to register, as defined by &enum vfl_devnode_type * @nr: which device node number is desired: - * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) + * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) * * Internally, it calls __video_register_device(). Please see its * documentation for more details. * * .. note:: - * if video_register_device fails, the release() callback of + * if video_register_device fails, the release() callback of * &struct video_device structure is *not* called, so the caller * is responsible for freeing any data. Usually that means that * you video_device_release() should be called on failure. @@ -375,7 +375,7 @@ static inline int __must_check video_register_device(struct video_device *vdev, * @vdev: struct video_device to register * @type: type of device to register, as defined by &enum vfl_devnode_type * @nr: which device node number is desired: - * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) + * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free) * * This function is identical to video_register_device() except that no * warning is issued if the desired device node number was already in use. @@ -384,7 +384,7 @@ static inline int __must_check video_register_device(struct video_device *vdev, * documentation for more details. * * .. note:: - * if video_register_device fails, the release() callback of + * if video_register_device fails, the release() callback of * &struct video_device structure is *not* called, so the caller * is responsible for freeing any data. Usually that means that * you video_device_release() should be called on failure. @@ -423,7 +423,7 @@ void video_device_release(struct video_device *vdev); /** * video_device_release_empty - helper function to implement the - * video_device->release\(\) callback. + * video_device->release\(\) callback. * * @vdev: pointer to &struct video_device * diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h index 4e83529117f7..17833e886e11 100644 --- a/include/media/v4l2-event.h +++ b/include/media/v4l2-event.h @@ -184,7 +184,7 @@ int v4l2_event_subdev_unsubscribe(struct v4l2_subdev *sd, struct v4l2_event_subscription *sub); /** * v4l2_src_change_event_subscribe - helper function that calls - * v4l2_event_subscribe() if the event is %V4L2_EVENT_SOURCE_CHANGE. + * v4l2_event_subscribe() if the event is %V4L2_EVENT_SOURCE_CHANGE. * * @fh: pointer to struct v4l2_fh * @sub: pointer to &struct v4l2_event_subscription diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 71b8ff4b2e0e..980a86c08fce 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -116,7 +116,7 @@ struct v4l2_decode_vbi_line { * @V4L2_SUBDEV_IO_PIN_OUTPUT: set it if pin is an output. * @V4L2_SUBDEV_IO_PIN_INPUT: set it if pin is an input. * @V4L2_SUBDEV_IO_PIN_SET_VALUE: to set the output value via - * &struct v4l2_subdev_io_pin_config->value. + * &struct v4l2_subdev_io_pin_config->value. * @V4L2_SUBDEV_IO_PIN_ACTIVE_LOW: pin active is bit 0. * Otherwise, ACTIVE HIGH is assumed. */ @@ -253,14 +253,14 @@ struct v4l2_subdev_core_ops { * * .. note:: * - * On devices that have both AM/FM and TV, it is up to the driver + * On devices that have both AM/FM and TV, it is up to the driver * to explicitly call s_radio when the tuner should be switched to * radio mode, before handling other &struct v4l2_subdev_tuner_ops * that would require it. An example of such usage is:: * * static void s_frequency(void *priv, const struct v4l2_frequency *f) * { - * ... + * ... * if (f.type == V4L2_TUNER_RADIO) * v4l2_device_call_all(v4l2_dev, 0, tuner, s_radio); * ... @@ -333,7 +333,7 @@ enum v4l2_mbus_frame_desc_flags { * * @flags: bitmask flags, as defined by &enum v4l2_mbus_frame_desc_flags. * @pixelcode: media bus pixel code, valid if @flags - * %FRAME_DESC_FL_BLOB is not set. + * %FRAME_DESC_FL_BLOB is not set. * @length: number of octets per frame, valid if @flags * %V4L2_MBUS_FRAME_DESC_FL_LEN_MAX is set. */ -- cgit From 6e6a8b5a38cb04d5ef35d4eb57836126b954e7c8 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 4 Jan 2018 13:08:56 -0500 Subject: media: replace all occurrences There are a lot of places where sequences of space/tabs are found. Get rid of all spaces before tabs. Signed-off-by: Mauro Carvalho Chehab --- include/media/drv-intf/cx2341x.h | 144 +++++++++++++++++++-------------------- include/media/drv-intf/msp3400.h | 62 ++++++++--------- include/media/drv-intf/saa7146.h | 2 +- include/media/i2c/bt819.h | 4 +- include/media/i2c/m52790.h | 52 +++++++------- include/media/i2c/saa7115.h | 12 ++-- include/media/i2c/upd64031a.h | 6 +- include/media/v4l2-common.h | 8 +-- 8 files changed, 145 insertions(+), 145 deletions(-) (limited to 'include/media') diff --git a/include/media/drv-intf/cx2341x.h b/include/media/drv-intf/cx2341x.h index 9635eebaab09..33a97bfcea58 100644 --- a/include/media/drv-intf/cx2341x.h +++ b/include/media/drv-intf/cx2341x.h @@ -29,8 +29,8 @@ enum cx2341x_port { enum cx2341x_cap { CX2341X_CAP_HAS_SLICED_VBI = 1 << 0, - CX2341X_CAP_HAS_TS = 1 << 1, - CX2341X_CAP_HAS_AC3 = 1 << 2, + CX2341X_CAP_HAS_TS = 1 << 1, + CX2341X_CAP_HAS_AC3 = 1 << 2, }; struct cx2341x_mpeg_params { @@ -204,92 +204,92 @@ void cx2341x_handler_set_busy(struct cx2341x_handler *cxhdl, int busy); /* Firmware API commands */ /* MPEG decoder API, specific to the cx23415 */ -#define CX2341X_DEC_PING_FW 0x00 -#define CX2341X_DEC_START_PLAYBACK 0x01 -#define CX2341X_DEC_STOP_PLAYBACK 0x02 -#define CX2341X_DEC_SET_PLAYBACK_SPEED 0x03 -#define CX2341X_DEC_STEP_VIDEO 0x05 -#define CX2341X_DEC_SET_DMA_BLOCK_SIZE 0x08 +#define CX2341X_DEC_PING_FW 0x00 +#define CX2341X_DEC_START_PLAYBACK 0x01 +#define CX2341X_DEC_STOP_PLAYBACK 0x02 +#define CX2341X_DEC_SET_PLAYBACK_SPEED 0x03 +#define CX2341X_DEC_STEP_VIDEO 0x05 +#define CX2341X_DEC_SET_DMA_BLOCK_SIZE 0x08 #define CX2341X_DEC_GET_XFER_INFO 0x09 #define CX2341X_DEC_GET_DMA_STATUS 0x0a #define CX2341X_DEC_SCHED_DMA_FROM_HOST 0x0b -#define CX2341X_DEC_PAUSE_PLAYBACK 0x0d -#define CX2341X_DEC_HALT_FW 0x0e -#define CX2341X_DEC_SET_STANDARD 0x10 +#define CX2341X_DEC_PAUSE_PLAYBACK 0x0d +#define CX2341X_DEC_HALT_FW 0x0e +#define CX2341X_DEC_SET_STANDARD 0x10 #define CX2341X_DEC_GET_VERSION 0x11 -#define CX2341X_DEC_SET_STREAM_INPUT 0x14 -#define CX2341X_DEC_GET_TIMING_INFO 0x15 -#define CX2341X_DEC_SET_AUDIO_MODE 0x16 +#define CX2341X_DEC_SET_STREAM_INPUT 0x14 +#define CX2341X_DEC_GET_TIMING_INFO 0x15 +#define CX2341X_DEC_SET_AUDIO_MODE 0x16 #define CX2341X_DEC_SET_EVENT_NOTIFICATION 0x17 #define CX2341X_DEC_SET_DISPLAY_BUFFERS 0x18 -#define CX2341X_DEC_EXTRACT_VBI 0x19 -#define CX2341X_DEC_SET_DECODER_SOURCE 0x1a +#define CX2341X_DEC_EXTRACT_VBI 0x19 +#define CX2341X_DEC_SET_DECODER_SOURCE 0x1a #define CX2341X_DEC_SET_PREBUFFERING 0x1e /* MPEG encoder API */ -#define CX2341X_ENC_PING_FW 0x80 -#define CX2341X_ENC_START_CAPTURE 0x81 -#define CX2341X_ENC_STOP_CAPTURE 0x82 -#define CX2341X_ENC_SET_AUDIO_ID 0x89 -#define CX2341X_ENC_SET_VIDEO_ID 0x8b -#define CX2341X_ENC_SET_PCR_ID 0x8d -#define CX2341X_ENC_SET_FRAME_RATE 0x8f -#define CX2341X_ENC_SET_FRAME_SIZE 0x91 -#define CX2341X_ENC_SET_BIT_RATE 0x95 -#define CX2341X_ENC_SET_GOP_PROPERTIES 0x97 -#define CX2341X_ENC_SET_ASPECT_RATIO 0x99 -#define CX2341X_ENC_SET_DNR_FILTER_MODE 0x9b -#define CX2341X_ENC_SET_DNR_FILTER_PROPS 0x9d -#define CX2341X_ENC_SET_CORING_LEVELS 0x9f -#define CX2341X_ENC_SET_SPATIAL_FILTER_TYPE 0xa1 -#define CX2341X_ENC_SET_VBI_LINE 0xb7 -#define CX2341X_ENC_SET_STREAM_TYPE 0xb9 -#define CX2341X_ENC_SET_OUTPUT_PORT 0xbb -#define CX2341X_ENC_SET_AUDIO_PROPERTIES 0xbd -#define CX2341X_ENC_HALT_FW 0xc3 +#define CX2341X_ENC_PING_FW 0x80 +#define CX2341X_ENC_START_CAPTURE 0x81 +#define CX2341X_ENC_STOP_CAPTURE 0x82 +#define CX2341X_ENC_SET_AUDIO_ID 0x89 +#define CX2341X_ENC_SET_VIDEO_ID 0x8b +#define CX2341X_ENC_SET_PCR_ID 0x8d +#define CX2341X_ENC_SET_FRAME_RATE 0x8f +#define CX2341X_ENC_SET_FRAME_SIZE 0x91 +#define CX2341X_ENC_SET_BIT_RATE 0x95 +#define CX2341X_ENC_SET_GOP_PROPERTIES 0x97 +#define CX2341X_ENC_SET_ASPECT_RATIO 0x99 +#define CX2341X_ENC_SET_DNR_FILTER_MODE 0x9b +#define CX2341X_ENC_SET_DNR_FILTER_PROPS 0x9d +#define CX2341X_ENC_SET_CORING_LEVELS 0x9f +#define CX2341X_ENC_SET_SPATIAL_FILTER_TYPE 0xa1 +#define CX2341X_ENC_SET_VBI_LINE 0xb7 +#define CX2341X_ENC_SET_STREAM_TYPE 0xb9 +#define CX2341X_ENC_SET_OUTPUT_PORT 0xbb +#define CX2341X_ENC_SET_AUDIO_PROPERTIES 0xbd +#define CX2341X_ENC_HALT_FW 0xc3 #define CX2341X_ENC_GET_VERSION 0xc4 -#define CX2341X_ENC_SET_GOP_CLOSURE 0xc5 -#define CX2341X_ENC_GET_SEQ_END 0xc6 -#define CX2341X_ENC_SET_PGM_INDEX_INFO 0xc7 +#define CX2341X_ENC_SET_GOP_CLOSURE 0xc5 +#define CX2341X_ENC_GET_SEQ_END 0xc6 +#define CX2341X_ENC_SET_PGM_INDEX_INFO 0xc7 #define CX2341X_ENC_SET_VBI_CONFIG 0xc8 -#define CX2341X_ENC_SET_DMA_BLOCK_SIZE 0xc9 +#define CX2341X_ENC_SET_DMA_BLOCK_SIZE 0xc9 #define CX2341X_ENC_GET_PREV_DMA_INFO_MB_10 0xca #define CX2341X_ENC_GET_PREV_DMA_INFO_MB_9 0xcb -#define CX2341X_ENC_SCHED_DMA_TO_HOST 0xcc -#define CX2341X_ENC_INITIALIZE_INPUT 0xcd -#define CX2341X_ENC_SET_FRAME_DROP_RATE 0xd0 -#define CX2341X_ENC_PAUSE_ENCODER 0xd2 -#define CX2341X_ENC_REFRESH_INPUT 0xd3 +#define CX2341X_ENC_SCHED_DMA_TO_HOST 0xcc +#define CX2341X_ENC_INITIALIZE_INPUT 0xcd +#define CX2341X_ENC_SET_FRAME_DROP_RATE 0xd0 +#define CX2341X_ENC_PAUSE_ENCODER 0xd2 +#define CX2341X_ENC_REFRESH_INPUT 0xd3 #define CX2341X_ENC_SET_COPYRIGHT 0xd4 -#define CX2341X_ENC_SET_EVENT_NOTIFICATION 0xd5 -#define CX2341X_ENC_SET_NUM_VSYNC_LINES 0xd6 -#define CX2341X_ENC_SET_PLACEHOLDER 0xd7 -#define CX2341X_ENC_MUTE_VIDEO 0xd9 -#define CX2341X_ENC_MUTE_AUDIO 0xda +#define CX2341X_ENC_SET_EVENT_NOTIFICATION 0xd5 +#define CX2341X_ENC_SET_NUM_VSYNC_LINES 0xd6 +#define CX2341X_ENC_SET_PLACEHOLDER 0xd7 +#define CX2341X_ENC_MUTE_VIDEO 0xd9 +#define CX2341X_ENC_MUTE_AUDIO 0xda #define CX2341X_ENC_SET_VERT_CROP_LINE 0xdb -#define CX2341X_ENC_MISC 0xdc +#define CX2341X_ENC_MISC 0xdc /* OSD API, specific to the cx23415 */ -#define CX2341X_OSD_GET_FRAMEBUFFER 0x41 -#define CX2341X_OSD_GET_PIXEL_FORMAT 0x42 -#define CX2341X_OSD_SET_PIXEL_FORMAT 0x43 -#define CX2341X_OSD_GET_STATE 0x44 -#define CX2341X_OSD_SET_STATE 0x45 -#define CX2341X_OSD_GET_OSD_COORDS 0x46 -#define CX2341X_OSD_SET_OSD_COORDS 0x47 -#define CX2341X_OSD_GET_SCREEN_COORDS 0x48 -#define CX2341X_OSD_SET_SCREEN_COORDS 0x49 -#define CX2341X_OSD_GET_GLOBAL_ALPHA 0x4a -#define CX2341X_OSD_SET_GLOBAL_ALPHA 0x4b -#define CX2341X_OSD_SET_BLEND_COORDS 0x4c -#define CX2341X_OSD_GET_FLICKER_STATE 0x4f -#define CX2341X_OSD_SET_FLICKER_STATE 0x50 -#define CX2341X_OSD_BLT_COPY 0x52 -#define CX2341X_OSD_BLT_FILL 0x53 -#define CX2341X_OSD_BLT_TEXT 0x54 -#define CX2341X_OSD_SET_FRAMEBUFFER_WINDOW 0x56 -#define CX2341X_OSD_SET_CHROMA_KEY 0x60 -#define CX2341X_OSD_GET_ALPHA_CONTENT_INDEX 0x61 -#define CX2341X_OSD_SET_ALPHA_CONTENT_INDEX 0x62 +#define CX2341X_OSD_GET_FRAMEBUFFER 0x41 +#define CX2341X_OSD_GET_PIXEL_FORMAT 0x42 +#define CX2341X_OSD_SET_PIXEL_FORMAT 0x43 +#define CX2341X_OSD_GET_STATE 0x44 +#define CX2341X_OSD_SET_STATE 0x45 +#define CX2341X_OSD_GET_OSD_COORDS 0x46 +#define CX2341X_OSD_SET_OSD_COORDS 0x47 +#define CX2341X_OSD_GET_SCREEN_COORDS 0x48 +#define CX2341X_OSD_SET_SCREEN_COORDS 0x49 +#define CX2341X_OSD_GET_GLOBAL_ALPHA 0x4a +#define CX2341X_OSD_SET_GLOBAL_ALPHA 0x4b +#define CX2341X_OSD_SET_BLEND_COORDS 0x4c +#define CX2341X_OSD_GET_FLICKER_STATE 0x4f +#define CX2341X_OSD_SET_FLICKER_STATE 0x50 +#define CX2341X_OSD_BLT_COPY 0x52 +#define CX2341X_OSD_BLT_FILL 0x53 +#define CX2341X_OSD_BLT_TEXT 0x54 +#define CX2341X_OSD_SET_FRAMEBUFFER_WINDOW 0x56 +#define CX2341X_OSD_SET_CHROMA_KEY 0x60 +#define CX2341X_OSD_GET_ALPHA_CONTENT_INDEX 0x61 +#define CX2341X_OSD_SET_ALPHA_CONTENT_INDEX 0x62 #endif /* CX2341X_H */ diff --git a/include/media/drv-intf/msp3400.h b/include/media/drv-intf/msp3400.h index 1e6e80213a77..db98ce49e17b 100644 --- a/include/media/drv-intf/msp3400.h +++ b/include/media/drv-intf/msp3400.h @@ -80,17 +80,17 @@ */ /* SCART input to DSP selection */ -#define MSP_IN_SCART1 0 /* Pin SC1_IN */ -#define MSP_IN_SCART2 1 /* Pin SC2_IN */ -#define MSP_IN_SCART3 2 /* Pin SC3_IN */ -#define MSP_IN_SCART4 3 /* Pin SC4_IN */ -#define MSP_IN_MONO 6 /* Pin MONO_IN */ -#define MSP_IN_MUTE 7 /* Mute DSP input */ -#define MSP_SCART_TO_DSP(in) (in) +#define MSP_IN_SCART1 0 /* Pin SC1_IN */ +#define MSP_IN_SCART2 1 /* Pin SC2_IN */ +#define MSP_IN_SCART3 2 /* Pin SC3_IN */ +#define MSP_IN_SCART4 3 /* Pin SC4_IN */ +#define MSP_IN_MONO 6 /* Pin MONO_IN */ +#define MSP_IN_MUTE 7 /* Mute DSP input */ +#define MSP_SCART_TO_DSP(in) (in) /* Tuner input to demodulator and DSP selection */ -#define MSP_IN_TUNER1 0 /* Analog Sound IF input pin ANA_IN1 */ -#define MSP_IN_TUNER2 1 /* Analog Sound IF input pin ANA_IN2 */ -#define MSP_TUNER_TO_DSP(in) ((in) << 3) +#define MSP_IN_TUNER1 0 /* Analog Sound IF input pin ANA_IN1 */ +#define MSP_IN_TUNER2 1 /* Analog Sound IF input pin ANA_IN2 */ +#define MSP_TUNER_TO_DSP(in) ((in) << 3) /* The msp has up to 5 DSP outputs, each output can independently select a DSP input. @@ -109,30 +109,30 @@ DSP. This is currently not implemented. Also not implemented is the multi-channel capable I2S3 input of the 44x0G. If someone can demonstrate a need for one of those features then additional support can be added. */ -#define MSP_DSP_IN_TUNER 0 /* Tuner DSP input */ -#define MSP_DSP_IN_SCART 2 /* SCART DSP input */ -#define MSP_DSP_IN_I2S1 5 /* I2S1 DSP input */ -#define MSP_DSP_IN_I2S2 6 /* I2S2 DSP input */ -#define MSP_DSP_IN_I2S3 7 /* I2S3 DSP input */ -#define MSP_DSP_IN_MAIN_AVC 11 /* MAIN AVC processed DSP input */ -#define MSP_DSP_IN_MAIN 12 /* MAIN DSP input */ -#define MSP_DSP_IN_AUX 13 /* AUX DSP input */ -#define MSP_DSP_TO_MAIN(in) ((in) << 4) -#define MSP_DSP_TO_AUX(in) ((in) << 8) -#define MSP_DSP_TO_SCART1(in) ((in) << 12) -#define MSP_DSP_TO_SCART2(in) ((in) << 16) -#define MSP_DSP_TO_I2S(in) ((in) << 20) +#define MSP_DSP_IN_TUNER 0 /* Tuner DSP input */ +#define MSP_DSP_IN_SCART 2 /* SCART DSP input */ +#define MSP_DSP_IN_I2S1 5 /* I2S1 DSP input */ +#define MSP_DSP_IN_I2S2 6 /* I2S2 DSP input */ +#define MSP_DSP_IN_I2S3 7 /* I2S3 DSP input */ +#define MSP_DSP_IN_MAIN_AVC 11 /* MAIN AVC processed DSP input */ +#define MSP_DSP_IN_MAIN 12 /* MAIN DSP input */ +#define MSP_DSP_IN_AUX 13 /* AUX DSP input */ +#define MSP_DSP_TO_MAIN(in) ((in) << 4) +#define MSP_DSP_TO_AUX(in) ((in) << 8) +#define MSP_DSP_TO_SCART1(in) ((in) << 12) +#define MSP_DSP_TO_SCART2(in) ((in) << 16) +#define MSP_DSP_TO_I2S(in) ((in) << 20) /* Output SCART select: the SCART outputs can select which input to use. */ -#define MSP_SC_IN_SCART1 0 /* SCART1 input, bypassing the DSP */ -#define MSP_SC_IN_SCART2 1 /* SCART2 input, bypassing the DSP */ -#define MSP_SC_IN_SCART3 2 /* SCART3 input, bypassing the DSP */ -#define MSP_SC_IN_SCART4 3 /* SCART4 input, bypassing the DSP */ -#define MSP_SC_IN_DSP_SCART1 4 /* DSP SCART1 input */ -#define MSP_SC_IN_DSP_SCART2 5 /* DSP SCART2 input */ -#define MSP_SC_IN_MONO 6 /* MONO input, bypassing the DSP */ -#define MSP_SC_IN_MUTE 7 /* MUTE output */ +#define MSP_SC_IN_SCART1 0 /* SCART1 input, bypassing the DSP */ +#define MSP_SC_IN_SCART2 1 /* SCART2 input, bypassing the DSP */ +#define MSP_SC_IN_SCART3 2 /* SCART3 input, bypassing the DSP */ +#define MSP_SC_IN_SCART4 3 /* SCART4 input, bypassing the DSP */ +#define MSP_SC_IN_DSP_SCART1 4 /* DSP SCART1 input */ +#define MSP_SC_IN_DSP_SCART2 5 /* DSP SCART2 input */ +#define MSP_SC_IN_MONO 6 /* MONO input, bypassing the DSP */ +#define MSP_SC_IN_MUTE 7 /* MUTE output */ #define MSP_SC_TO_SCART1(in) (in) #define MSP_SC_TO_SCART2(in) ((in) << 4) diff --git a/include/media/drv-intf/saa7146.h b/include/media/drv-intf/saa7146.h index 769c6cf7eb4c..a7bf2c4a2e4d 100644 --- a/include/media/drv-intf/saa7146.h +++ b/include/media/drv-intf/saa7146.h @@ -118,7 +118,7 @@ struct saa7146_dev { struct module *module; - struct v4l2_device v4l2_dev; + struct v4l2_device v4l2_dev; struct v4l2_ctrl_handler ctrl_handler; /* different device locks */ diff --git a/include/media/i2c/bt819.h b/include/media/i2c/bt819.h index 8025f4bc2bb6..1bcf0dbeb516 100644 --- a/include/media/i2c/bt819.h +++ b/include/media/i2c/bt819.h @@ -30,7 +30,7 @@ Note: these ioctls that internal to the kernel and are never called from userspace. */ -#define BT819_FIFO_RESET_LOW _IO('b', 0) -#define BT819_FIFO_RESET_HIGH _IO('b', 1) +#define BT819_FIFO_RESET_LOW _IO('b', 0) +#define BT819_FIFO_RESET_HIGH _IO('b', 1) #endif diff --git a/include/media/i2c/m52790.h b/include/media/i2c/m52790.h index 7ddffae31a67..8d9db3cf6fab 100644 --- a/include/media/i2c/m52790.h +++ b/include/media/i2c/m52790.h @@ -23,57 +23,57 @@ /* Input routing switch 1 */ -#define M52790_SW1_IN_MASK 0x0003 -#define M52790_SW1_IN_TUNER 0x0000 -#define M52790_SW1_IN_V2 0x0001 -#define M52790_SW1_IN_V3 0x0002 -#define M52790_SW1_IN_V4 0x0003 +#define M52790_SW1_IN_MASK 0x0003 +#define M52790_SW1_IN_TUNER 0x0000 +#define M52790_SW1_IN_V2 0x0001 +#define M52790_SW1_IN_V3 0x0002 +#define M52790_SW1_IN_V4 0x0003 /* Selects component input instead of composite */ -#define M52790_SW1_YCMIX 0x0004 +#define M52790_SW1_YCMIX 0x0004 /* Input routing switch 2 */ -#define M52790_SW2_IN_MASK 0x0300 -#define M52790_SW2_IN_TUNER 0x0000 -#define M52790_SW2_IN_V2 0x0100 -#define M52790_SW2_IN_V3 0x0200 -#define M52790_SW2_IN_V4 0x0300 +#define M52790_SW2_IN_MASK 0x0300 +#define M52790_SW2_IN_TUNER 0x0000 +#define M52790_SW2_IN_V2 0x0100 +#define M52790_SW2_IN_V3 0x0200 +#define M52790_SW2_IN_V4 0x0300 /* Selects component input instead of composite */ -#define M52790_SW2_YCMIX 0x0400 +#define M52790_SW2_YCMIX 0x0400 /* Output routing switch 1 */ /* Enable 6dB amplifier for composite out */ -#define M52790_SW1_V_AMP 0x0008 +#define M52790_SW1_V_AMP 0x0008 /* Enable 6dB amplifier for component out */ -#define M52790_SW1_YC_AMP 0x0010 +#define M52790_SW1_YC_AMP 0x0010 /* Audio output mode */ -#define M52790_SW1_AUDIO_MASK 0x00c0 -#define M52790_SW1_AUDIO_MUTE 0x0000 -#define M52790_SW1_AUDIO_R 0x0040 -#define M52790_SW1_AUDIO_L 0x0080 +#define M52790_SW1_AUDIO_MASK 0x00c0 +#define M52790_SW1_AUDIO_MUTE 0x0000 +#define M52790_SW1_AUDIO_R 0x0040 +#define M52790_SW1_AUDIO_L 0x0080 #define M52790_SW1_AUDIO_STEREO 0x00c0 /* Output routing switch 2 */ /* Enable 6dB amplifier for composite out */ -#define M52790_SW2_V_AMP 0x0800 +#define M52790_SW2_V_AMP 0x0800 /* Enable 6dB amplifier for component out */ -#define M52790_SW2_YC_AMP 0x1000 +#define M52790_SW2_YC_AMP 0x1000 /* Audio output mode */ -#define M52790_SW2_AUDIO_MASK 0xc000 -#define M52790_SW2_AUDIO_MUTE 0x0000 -#define M52790_SW2_AUDIO_R 0x4000 -#define M52790_SW2_AUDIO_L 0x8000 +#define M52790_SW2_AUDIO_MASK 0xc000 +#define M52790_SW2_AUDIO_MUTE 0x0000 +#define M52790_SW2_AUDIO_R 0x4000 +#define M52790_SW2_AUDIO_L 0x8000 #define M52790_SW2_AUDIO_STEREO 0xc000 @@ -83,9 +83,9 @@ #define M52790_IN_V3 (M52790_SW1_IN_V3 | M52790_SW2_IN_V3) #define M52790_IN_V4 (M52790_SW1_IN_V4 | M52790_SW2_IN_V4) -#define M52790_OUT_STEREO (M52790_SW1_AUDIO_STEREO | \ +#define M52790_OUT_STEREO (M52790_SW1_AUDIO_STEREO | \ M52790_SW2_AUDIO_STEREO) -#define M52790_OUT_AMP_STEREO (M52790_SW1_AUDIO_STEREO | \ +#define M52790_OUT_AMP_STEREO (M52790_SW1_AUDIO_STEREO | \ M52790_SW1_V_AMP | \ M52790_SW2_AUDIO_STEREO | \ M52790_SW2_V_AMP) diff --git a/include/media/i2c/saa7115.h b/include/media/i2c/saa7115.h index 53954c90e7f6..a0cda423509d 100644 --- a/include/media/i2c/saa7115.h +++ b/include/media/i2c/saa7115.h @@ -36,15 +36,15 @@ #define SAA7115_SVIDEO3 9 /* outputs */ -#define SAA7115_IPORT_ON 1 -#define SAA7115_IPORT_OFF 0 +#define SAA7115_IPORT_ON 1 +#define SAA7115_IPORT_OFF 0 /* SAA7111 specific outputs. */ -#define SAA7111_VBI_BYPASS 2 +#define SAA7111_VBI_BYPASS 2 #define SAA7111_FMT_YUV422 0x00 -#define SAA7111_FMT_RGB 0x40 -#define SAA7111_FMT_CCIR 0x80 -#define SAA7111_FMT_YUV411 0xc0 +#define SAA7111_FMT_RGB 0x40 +#define SAA7111_FMT_CCIR 0x80 +#define SAA7111_FMT_YUV411 0xc0 /* config flags */ /* diff --git a/include/media/i2c/upd64031a.h b/include/media/i2c/upd64031a.h index 48ec03c4ef23..1eba24dfee48 100644 --- a/include/media/i2c/upd64031a.h +++ b/include/media/i2c/upd64031a.h @@ -18,9 +18,9 @@ #define _UPD64031A_H_ /* Ghost reduction modes */ -#define UPD64031A_GR_ON 0 -#define UPD64031A_GR_OFF 1 -#define UPD64031A_GR_THROUGH 3 +#define UPD64031A_GR_ON 0 +#define UPD64031A_GR_OFF 1 +#define UPD64031A_GR_THROUGH 3 /* Direct 3D/YCS Connection */ #define UPD64031A_3DYCS_DISABLE (0 << 2) diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index 7fc0bc6b8007..e0d95a7c5d48 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -50,7 +50,7 @@ /* These three macros assume that the debug level is set with a module parameter called 'debug'. */ #define v4l_dbg(level, debug, client, fmt, arg...) \ - do { \ + do { \ if (debug >= (level)) \ v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \ } while (0) @@ -80,9 +80,9 @@ /* These three macros assume that the debug level is set with a module parameter called 'debug'. */ #define v4l2_dbg(level, debug, dev, fmt, arg...) \ - do { \ + do { \ if (debug >= (level)) \ - v4l2_printk(KERN_DEBUG, dev, fmt , ## arg); \ + v4l2_printk(KERN_DEBUG, dev, fmt , ## arg); \ } while (0) /** @@ -266,7 +266,7 @@ struct v4l2_priv_tun_config { }; #define TUNER_SET_CONFIG _IOW('d', 92, struct v4l2_priv_tun_config) -#define VIDIOC_INT_RESET _IOW ('d', 102, u32) +#define VIDIOC_INT_RESET _IOW ('d', 102, u32) /* ------------------------------------------------------------------------- */ -- cgit From 3580112b6d6f51725ba605c146db14af61e87628 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Tue, 9 Jan 2018 05:20:34 -0500 Subject: media: entity: Add a nop variant of media_entity_cleanup Add nop variant of media_entity_cleanup. This allows calling media_entity_cleanup whether or not Media controller is enabled, simplifying driver code. Also drop #ifdefs on a few drivers around media_entity_cleanup(). Signed-off-by: Sakari Ailus Reviewed-by: Arnd Bergmann Signed-off-by: Mauro Carvalho Chehab --- include/media/media-entity.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/media-entity.h b/include/media/media-entity.h index d7a669058b5e..a732af1dbba0 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -634,7 +634,11 @@ int media_entity_pads_init(struct media_entity *entity, u16 num_pads, * This function must be called during the cleanup phase after unregistering * the entity (currently, it does nothing). */ -static inline void media_entity_cleanup(struct media_entity *entity) {}; +#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER) +static inline void media_entity_cleanup(struct media_entity *entity) {} +#else +#define media_entity_cleanup(entity) do { } while (false) +#endif /** * media_create_pad_link() - creates a link between two entities. -- cgit