Digital TV Common functions
DVB devices #
Those functions are responsible for handling the DVB device nodes.
enum dvb_device_type #
type of the Digital TV device
Constants
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.
struct dvb_adapter #
represents a Digital TV adapter using Linux DVB API
Definition
;
Members
num: Number of the adapterlist_head: List with the DVB adaptersdevice_list: List with the DVB devicesname: Name of the adapterproposed_mac: proposed MAC address for the adapterpriv: private datadevice: pointer to struct devicemodule: pointer to struct modulemfe_shared: indicates mutually exclusive frontends. 1 = legacy exclusion behavior: blocking anyopen()call 2 = enhanced exclusion behavior, emulating the standard behavior of busy frontends: allowing read-only sharing and otherwise returning immediately with -EBUSY when any of the frontends is already opened with write access.mfe_dvbdev: Frontend device in use, in the case of MFEmfe_lock: Lock to prevent using the other frontends when MFE is used.mdev_lock: Protect access to the mdev pointer.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_device #
represents a DVB device node
Definition
;
Members
list_head: List head with all DVB devicesref: reference count for this devicefops: pointer to struct file_operationsadapter: pointer to the adapter that holds this device nodetype: type of the device, as defined byenum dvb_device_type.minor: devnode minor number. Major number is always DVB_MAJOR.id: device ID number, inside the adapterreaders: Initialized by the caller. Each call toopen()in Read Only mode decreases this counter by one.writers: Initialized by the caller. Each call toopen()in Read/Write mode decreases this counter by one.users: Initialized by the caller. Each call toopen()in any mode decreases this counter by one.wait_queue: wait queue, used to wait for certain events inside one of the DVB API callerskernel_ioctl: callback function used to handle ioctl calls from userspace.name: Name to be used for the device at the Media Controllerintf_devnode: Pointer to media_intf_devnode. Used by the dvbdev core to store the MC device node interfacetsout_num_entities: Number of Transport Stream output entitiesentity: pointer to struct media_entity associated with the device nodetsout_entity: array with MC entities associated to each TS output nodepads: pointer to struct media_pad associated with entity;tsout_pads: array with the source pads for each tsout_entitypriv: private data
Description
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 dvbdevfops_node #
fops nodes registered in dvbdevfops_list
Definition
;
Members
fops: Dynamically allocated fops for ->owner registrationtype: type of dvb_devicetemplate: dvb_device used for registrationlist_head: list_head for dvbdevfops_list
dvb_device_get() #
struct dvb_device * Increase dvb_device reference
Parameters
struct dvb_device *dvbdev: pointer to struct dvb_device
dvb_device_put() #
void Decrease dvb_device reference
Parameters
struct dvb_device *dvbdev: pointer to struct dvb_device
dvb_register_adapter() #
int Registers a new DVB adapter
Parameters
struct dvb_adapter *adap: pointer to struct dvb_adapterconst char *name: Adapter's namestruct module *module: initialized with THIS_MODULE at the callerstruct device *device: pointer to struct device that corresponds to the device drivershort *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)
dvb_unregister_adapter() #
int Unregisters a DVB adapter
Parameters
struct dvb_adapter *adap: pointer to struct dvb_adapter
dvb_register_device() #
int Registers a new DVB device
Parameters
struct dvb_adapter *adap: pointer to struct dvb_adapterstruct dvb_device **pdvbdev: pointer to the place where the new struct dvb_device will be storedconst struct dvb_device *template: Template used to createpdvbdev;void *priv: private dataenum dvb_device_type type: type of the device, as defined byenum dvb_device_type.int demux_sink_pads: Number of demux outputs, to be used to create the TS outputs via the Media Controller.
dvb_remove_device() #
void Remove a registered DVB device
Parameters
struct dvb_device *dvbdev: pointer to struct dvb_device
Description
This does not free memory. dvb_free_device() will do that when
reference counter is empty
dvb_unregister_device() #
void Unregisters a DVB device
Parameters
struct dvb_device *dvbdev: pointer to struct dvb_device
dvb_create_media_graph() #
int Creates media graph for the Digital TV part of the device.
Parameters
struct dvb_adapter *adap: pointer tostruct dvb_adapterbool create_rf_connector: if true, it creates the RF connector too
Description
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.
dvb_register_media_controller() #
void registers a media controller at DVB adapter
Parameters
struct dvb_adapter *adap: pointer tostruct dvb_adapterstruct media_device *mdev: pointer tostruct media_device
dvb_get_media_controller() #
struct media_device * gets the associated media controller
Parameters
struct dvb_adapter *adap: pointer tostruct dvb_adapter
dvb_generic_open() #
int Digital TV open function, used by DVB devices
Parameters
struct inode *inode: pointer tostruct inode.struct file *file: pointer tostruct file.
Description
Checks if a DVB devnode is still valid, and if the permissions are OK and increment negative use count.
dvb_generic_release() #
int Digital TV close function, used by DVB devices
Parameters
struct inode *inode: pointer tostruct inode.struct file *file: pointer tostruct file.
Description
Checks if a DVB devnode is still valid, and if the permissions are OK and decrement negative use count.
dvb_generic_ioctl() #
long Digital TV close function, used by DVB devices
Parameters
struct file *file: pointer tostruct file.unsigned int cmd: Ioctl name.unsigned long arg: Ioctl argument.
Description
Checks if a DVB devnode and struct dvbdev.kernel_ioctl is still valid.
If so, calls dvb_usercopy().
dvb_usercopy() #
int copies data from/to userspace memory when an ioctl is issued.
Parameters
struct file *file: Pointer to structfile.unsigned int cmd: Ioctl name.unsigned long arg: Ioctl argument.int (*func)(struct file *file, unsigned int cmd, void *arg): function that will actually handle the ioctl
Description
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.
dvb_module_probe() #
struct i2c_client * helper routine to probe an I2C module
Parameters
const char *module_name: Name of the I2C module to be probedconst char *name: Optional name for the I2C module. Used for debug purposes. IfNULL, defaults to module_name.struct i2c_adapter *adap: pointer tostruct i2c_adapterthat describes the I2C adapter where the module will be bound.unsigned char addr: I2C address of the adapter, in 7-bit notation.void *platform_data: Platform data to be passed to the I2C module probed.
Description
This function binds an I2C device into the DVB core. Should be used by
all drivers that use I2C bus to control the hardware. A module bound
with dvb_module_probe() should use dvb_module_release() to unbind.
Return
On success, return an struct i2c_client, pointing to the bound
I2C device. NULL otherwise.
dvb_module_release() #
void releases an I2C device allocated with dvb_module_probe().
Parameters
struct i2c_client *client: pointer tostruct i2c_clientwith the I2C client to be released. can beNULL.
Description
This function should be used to free all resources reserved by
dvb_module_probe() and unbinding the I2C hardware.
dvb_attach() #
attaches a DVB frontend into the DVB core.
Parameters
-
FUNCTION: function on a frontend module to be called. -
ARGS...:FUNCTION arguments.
Description
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.
dvb_detach() #
detaches a DVB frontend loaded via dvb_attach()
Parameters
FUNC: attach function
Description
Decrements usage count for a function previously called via dvb_attach().
Digital TV Ring buffer #
Those routines implement ring buffers used to handle digital TV data and copy it from/to userspace.
struct dvb_ringbuffer #
Describes a ring buffer used at DVB framework
Definition
;
Members
data: Area were the ringbuffer data is writtensize: size of the ringbufferpread: next position to readpwrite: next position to writeerror: used by ringbuffer clients to indicate that an error happened.queue: Wait queue used by ringbuffer clients to indicate when buffer was filledlock: Spinlock used to protect the ringbuffer
dvb_ringbuffer_init() #
void initialize ring buffer, lock and queue
Parameters
struct dvb_ringbuffer *rbuf: pointer to struct dvb_ringbuffervoid *data: pointer to the buffer where the data will be storedsize_t len: bytes from ring buffer into buf
dvb_ringbuffer_empty() #
int test whether buffer is empty
Parameters
struct dvb_ringbuffer *rbuf: pointer to struct dvb_ringbuffer
dvb_ringbuffer_free() #
ssize_t returns the number of free bytes in the buffer
Parameters
struct dvb_ringbuffer *rbuf: pointer to struct dvb_ringbuffer
Return
number of free bytes in the buffer
dvb_ringbuffer_avail() #
ssize_t returns the number of bytes waiting in the buffer
Parameters
struct dvb_ringbuffer *rbuf: pointer to struct dvb_ringbuffer
Return
number of bytes waiting in the buffer
dvb_ringbuffer_reset() #
void resets the ringbuffer to initial state
Parameters
struct dvb_ringbuffer *rbuf: pointer to struct dvb_ringbuffer
Description
Resets the read and write pointers to zero and flush the buffer.
This counts as a read and write operation
dvb_ringbuffer_flush() #
void flush buffer
Parameters
struct dvb_ringbuffer *rbuf: pointer to struct dvb_ringbuffer
dvb_ringbuffer_flush_spinlock_wakeup() #
void flush buffer protected by spinlock and wake-up waiting task(s)
Parameters
struct dvb_ringbuffer *rbuf: pointer to struct dvb_ringbuffer
DVB_RINGBUFFER_PEEK() #
peek at byte offs in the buffer
Parameters
rbuf: pointer to struct dvb_ringbufferoffs: offset inside the ringbuffer
DVB_RINGBUFFER_SKIP() #
advance read ptr by num bytes
Parameters
rbuf: pointer to struct dvb_ringbuffernum: number of bytes to advance
dvb_ringbuffer_read_user() #
ssize_t Reads a buffer into a user pointer
Parameters
struct dvb_ringbuffer *rbuf: pointer to struct dvb_ringbufferu8 __user *buf: pointer to the buffer where the data will be storedsize_t len: bytes from ring buffer into buf
Description
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
dvb_ringbuffer_read() #
void Reads a buffer into a pointer
Parameters
struct dvb_ringbuffer *rbuf: pointer to struct dvb_ringbufferu8 *buf: pointer to the buffer where the data will be storedsize_t len: bytes from ring buffer into buf
Description
This variant assumes that the buffer is a memory at the Kernel space
Return
number of bytes transferred or -EFAULT
DVB_RINGBUFFER_WRITE_BYTE() #
write single byte to ring buffer
Parameters
rbuf: pointer to struct dvb_ringbufferbyte: byte to write
dvb_ringbuffer_write() #
ssize_t Writes a buffer into the ringbuffer
Parameters
struct dvb_ringbuffer *rbuf: pointer to struct dvb_ringbufferconst u8 *buf: pointer to the buffer where the data will be readsize_t len: bytes from ring buffer into buf
Description
This variant assumes that the buffer is a memory at the Kernel space
Return
number of bytes transferred or -EFAULT
dvb_ringbuffer_write_user() #
ssize_t Writes a buffer received via a user pointer
Parameters
struct dvb_ringbuffer *rbuf: pointer to struct dvb_ringbufferconst u8 __user *buf: pointer to the buffer where the data will be readsize_t len: bytes from ring buffer into buf
Description
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
dvb_ringbuffer_pkt_write() #
ssize_t Write a packet into the ringbuffer.
Parameters
struct dvb_ringbuffer *rbuf: Ringbuffer to write to.u8 *buf: Buffer to write.size_t len: Length of buffer (currently limited to 65535 bytes max).
Return
Number of bytes written, or -EFAULT, -ENOMEM, -EINVAL.
dvb_ringbuffer_pkt_read_user() #
ssize_t Read from a packet in the ringbuffer.
Parameters
struct dvb_ringbuffer *rbuf: Ringbuffer concerned.size_t idx: Packet index as returned bydvb_ringbuffer_pkt_next().int offset: Offset into packet to read from.u8 __user *buf: Destination buffer for data.size_t len: Size of destination buffer.
Return
Number of bytes read, or -EFAULT.
Description
dvb_ringbuffer_pkt_read() #
ssize_t Read from a packet in the ringbuffer.
Parameters
struct dvb_ringbuffer *rbuf: Ringbuffer concerned.size_t idx: Packet index as returned bydvb_ringbuffer_pkt_next().int offset: Offset into packet to read from.u8 *buf: Destination buffer for data.size_t len: Size of destination buffer.
Note
unlike dvb_ringbuffer_read_user(), this DOES update the read pointer
in the ringbuffer.
Return
Number of bytes read, or -EFAULT.
dvb_ringbuffer_pkt_dispose() #
void Dispose of a packet in the ring buffer.
Parameters
struct dvb_ringbuffer *rbuf: Ring buffer concerned.size_t idx: Packet index as returned bydvb_ringbuffer_pkt_next().
dvb_ringbuffer_pkt_next() #
ssize_t Get the index of the next packet in a ringbuffer.
Parameters
struct dvb_ringbuffer *rbuf: Ringbuffer concerned.size_t idx: Previous packet index, or -1 to return the first packet index.size_t *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.
Digital TV VB2 handler #
enum dvb_buf_type #
types of Digital TV memory-mapped buffers
Constants
DVB_BUF_TYPE_CAPTURE: buffer is filled by the Kernel, with a received Digital TV stream
enum dvb_vb2_states #
states to control VB2 state machine
Constants
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 requestedDVB_VB2_STATE_STREAMON: VB2 is streaming. Callers should not check it directly. Instead, they should usedvb_vb2_is_streaming().
Note
Callers should not touch at the state machine directly. This is handled inside dvb_vb2.c.
struct dvb_buffer #
video buffer information for v4l2.
Definition
;
Members
vb: embedded structvb2_buffer.list: list ofstruct dvb_buffer.
struct dvb_vb2_ctx #
control struct for VB2 handler
Definition
;
Members
vb_q: pointer tostruct vb2_queuewith videobuf2 queue.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 byenum 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.flags: buffer flags as defined byenum dmx_buffer_flags. Filled only atDMX_DQBUF.DMX_QBUFshould zero this field.count: monotonic counter for filled buffers. Helps to identify data stream loses. Filled only atDMX_DQBUF.DMX_QBUFshould zero this field.name: name of the device type. Currently, it can either be "dvr" or "demux_filter".
dvb_vb2_init() #
int initializes VB2 handler
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handlerconst char *name: name for the VB2 handlerstruct mutex *mutex: pointer to the mutex that serializes vb2 ioctlsint non_blocking: if not zero, it means that the device is at non-blocking mode
dvb_vb2_release() #
int Releases the VB2 handler allocated resources and put ctx at DVB_VB2_STATE_NONE state.
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handler
dvb_vb2_is_streaming() #
int checks if the VB2 handler is streaming
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handler
Return
0 if not streaming, 1 otherwise.
dvb_vb2_fill_buffer() #
int fills a VB2 buffer
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handlerconst unsigned char *src: place where the data is storedint len: number of bytes to be copied from srcenum dmx_buffer_flags *buffer_flags: pointer to buffer flags as defined byenum dmx_buffer_flags. can be NULL.bool flush: flush the buffer, even if it isn't full.
dvb_vb2_poll() #
__poll_t Wrapper to vb2_core_streamon() for Digital TV buffer handling.
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handlerstruct file *file:struct fileargument passed to the poll file operation handler.poll_table *wait:poll_tablewait argument passed to the poll file operation handler.
Description
Implements poll syscall() logic.
dvb_vb2_stream_on() #
int Wrapper to vb2_core_streamon() for Digital TV buffer handling.
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handler
Description
Starts dvb streaming
dvb_vb2_stream_off() #
int Wrapper to vb2_core_streamoff() for Digital TV buffer handling.
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handler
Description
Stops dvb streaming
dvb_vb2_reqbufs() #
int Wrapper to vb2_core_reqbufs() for Digital TV buffer handling.
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handlerstruct dmx_requestbuffers *req:struct dmx_requestbufferspassed from userspace in order to handleDMX_REQBUFS.
Description
Initiate streaming by requesting a number of buffers. Also used to
free previously requested buffers, is req->count is zero.
dvb_vb2_querybuf() #
int Wrapper to vb2_core_querybuf() for Digital TV buffer handling.
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handlerstruct dmx_buffer *b:struct dmx_bufferpassed from userspace in order to handleDMX_QUERYBUF.
dvb_vb2_expbuf() #
int Wrapper to vb2_core_expbuf() for Digital TV buffer handling.
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handlerstruct dmx_exportbuffer *exp:struct dmx_exportbufferpassed from userspace in order to handleDMX_EXPBUF.
Description
Export a buffer as a file descriptor.
dvb_vb2_qbuf() #
int Wrapper to vb2_core_qbuf() for Digital TV buffer handling.
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handlerstruct dmx_buffer *b:struct dmx_bufferpassed from userspace in order to handleDMX_QBUF.
Description
Queue a Digital TV buffer as requested by userspace
dvb_vb2_dqbuf() #
int Wrapper to vb2_core_dqbuf() for Digital TV buffer handling.
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handlerstruct dmx_buffer *b:struct dmx_bufferpassed from userspace in order to handleDMX_DQBUF.
Description
Dequeue a Digital TV buffer to the userspace
dvb_vb2_mmap() #
int Wrapper to vb2_mmap() for Digital TV buffer handling.
Parameters
struct dvb_vb2_ctx *ctx: control struct for VB2 handlerstruct vm_area_struct *vma: pointer tostruct vm_area_structwith the vma passed to the mmap file operation handler in the driver.
Description
map Digital TV video buffers into application address space.