.. -*- coding: utf-8; mode: rst -*- media.h ======= .. parsed-literal:: \/\* SPDX-License-Identifier\: GPL-2.0 WITH Linux-syscall-note \*\/ \/\* \* Multimedia device API \* \* Copyright (C) 2010 Nokia Corporation \* \* Contacts\: Laurent Pinchart \ \* Sakari Ailus \ \* \* 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 \_\_LINUX\_MEDIA\_H \#define \_\_LINUX\_MEDIA\_H \#include \ \#include \ struct media_device_info \{ char driver[16]; char model[32]; char serial[40]; char bus\_info[32]; \_\_u32 media\_version; \_\_u32 hw\_revision; \_\_u32 driver\_version; \_\_u32 reserved[31]; \}; \/\* \* Base number ranges for entity functions \* \* NOTE\: Userspace should not rely on these ranges to identify a group \* of function types, as newer functions can be added with any name within \* the full u32 range. \* \* Some older functions use the MEDIA\_ENT\_F\_OLD\_\*\_BASE range. Do not \* change this, this is for backwards compatibility. When adding new \* functions always use MEDIA\_ENT\_F\_BASE. \*\/ \#define MEDIA\_ENT\_F\_BASE 0x00000000 \#define MEDIA\_ENT\_F\_OLD\_BASE 0x00010000 \#define MEDIA\_ENT\_F\_OLD\_SUBDEV\_BASE 0x00020000 \/\* \* Initial value to be used when a new entity is created \* Drivers should change it to something useful. \*\/ \#define \ :ref:`MEDIA_ENT_F_UNKNOWN ` MEDIA\_ENT\_F\_BASE \/\* \* Subdevs are initialized with \ :ref:`MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ` in order \* to preserve backward compatibility. Drivers must change to the proper \* subdev type before registering the entity. \*\/ \#define \ :ref:`MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ` MEDIA\_ENT\_F\_OLD\_SUBDEV\_BASE \/\* \* DVB entity functions \*\/ \#define \ :ref:`MEDIA_ENT_F_DTV_DEMOD ` (MEDIA\_ENT\_F\_BASE + 0x00001) \#define \ :ref:`MEDIA_ENT_F_TS_DEMUX ` (MEDIA\_ENT\_F\_BASE + 0x00002) \#define \ :ref:`MEDIA_ENT_F_DTV_CA ` (MEDIA\_ENT\_F\_BASE + 0x00003) \#define \ :ref:`MEDIA_ENT_F_DTV_NET_DECAP ` (MEDIA\_ENT\_F\_BASE + 0x00004) \/\* \* I\/O entity functions \*\/ \#define \ :ref:`MEDIA_ENT_F_IO_V4L ` (MEDIA\_ENT\_F\_OLD\_BASE + 1) \#define \ :ref:`MEDIA_ENT_F_IO_DTV ` (MEDIA\_ENT\_F\_BASE + 0x01001) \#define \ :ref:`MEDIA_ENT_F_IO_VBI ` (MEDIA\_ENT\_F\_BASE + 0x01002) \#define \ :ref:`MEDIA_ENT_F_IO_SWRADIO ` (MEDIA\_ENT\_F\_BASE + 0x01003) \/\* \* Sensor functions \*\/ \#define \ :ref:`MEDIA_ENT_F_CAM_SENSOR ` (MEDIA\_ENT\_F\_OLD\_SUBDEV\_BASE + 1) \#define \ :ref:`MEDIA_ENT_F_FLASH ` (MEDIA\_ENT\_F\_OLD\_SUBDEV\_BASE + 2) \#define \ :ref:`MEDIA_ENT_F_LENS ` (MEDIA\_ENT\_F\_OLD\_SUBDEV\_BASE + 3) \/\* \* Digital TV, analog TV, radio and\/or software defined radio tuner functions. \* \* It is a responsibility of the master\/bridge drivers to add connectors \* and links for MEDIA\_ENT\_F\_TUNER. Please notice that some old tuners \* may require the usage of separate I2C chips to decode analog TV signals, \* when the master\/bridge chipset doesn't have its own TV standard decoder. \* On such cases, the IF-PLL staging is mapped via one or two entities\: \* \ :ref:`MEDIA_ENT_F_IF_VID_DECODER ` and\/or MEDIA\_ENT\_F\_IF\_AUD\_DECODER. \*\/ \#define \ :ref:`MEDIA_ENT_F_TUNER ` (MEDIA\_ENT\_F\_OLD\_SUBDEV\_BASE + 5) \/\* \* Analog TV IF-PLL decoder functions \* \* It is a responsibility of the master\/bridge drivers to create links \* for \ :ref:`MEDIA_ENT_F_IF_VID_DECODER ` and MEDIA\_ENT\_F\_IF\_AUD\_DECODER. \*\/ \#define \ :ref:`MEDIA_ENT_F_IF_VID_DECODER ` (MEDIA\_ENT\_F\_BASE + 0x02001) \#define \ :ref:`MEDIA_ENT_F_IF_AUD_DECODER ` (MEDIA\_ENT\_F\_BASE + 0x02002) \/\* \* Audio entity functions \*\/ \#define \ :ref:`MEDIA_ENT_F_AUDIO_CAPTURE ` (MEDIA\_ENT\_F\_BASE + 0x03001) \#define \ :ref:`MEDIA_ENT_F_AUDIO_PLAYBACK ` (MEDIA\_ENT\_F\_BASE + 0x03002) \#define \ :ref:`MEDIA_ENT_F_AUDIO_MIXER ` (MEDIA\_ENT\_F\_BASE + 0x03003) \/\* \* Processing entity functions \*\/ \#define \ :ref:`MEDIA_ENT_F_PROC_VIDEO_COMPOSER ` (MEDIA\_ENT\_F\_BASE + 0x4001) \#define \ :ref:`MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER ` (MEDIA\_ENT\_F\_BASE + 0x4002) \#define \ :ref:`MEDIA_ENT_F_PROC_VIDEO_PIXEL_ENC_CONV ` (MEDIA\_ENT\_F\_BASE + 0x4003) \#define \ :ref:`MEDIA_ENT_F_PROC_VIDEO_LUT ` (MEDIA\_ENT\_F\_BASE + 0x4004) \#define \ :ref:`MEDIA_ENT_F_PROC_VIDEO_SCALER ` (MEDIA\_ENT\_F\_BASE + 0x4005) \#define \ :ref:`MEDIA_ENT_F_PROC_VIDEO_STATISTICS ` (MEDIA\_ENT\_F\_BASE + 0x4006) \#define \ :ref:`MEDIA_ENT_F_PROC_VIDEO_ENCODER ` (MEDIA\_ENT\_F\_BASE + 0x4007) \#define \ :ref:`MEDIA_ENT_F_PROC_VIDEO_DECODER ` (MEDIA\_ENT\_F\_BASE + 0x4008) \#define \ :ref:`MEDIA_ENT_F_PROC_VIDEO_ISP ` (MEDIA\_ENT\_F\_BASE + 0x4009) \/\* \* Switch and bridge entity functions \*\/ \#define \ :ref:`MEDIA_ENT_F_VID_MUX ` (MEDIA\_ENT\_F\_BASE + 0x5001) \#define \ :ref:`MEDIA_ENT_F_VID_IF_BRIDGE ` (MEDIA\_ENT\_F\_BASE + 0x5002) \/\* \* Video decoder\/encoder functions \*\/ \#define \ :ref:`MEDIA_ENT_F_ATV_DECODER ` (MEDIA\_ENT\_F\_OLD\_SUBDEV\_BASE + 4) \#define \ :ref:`MEDIA_ENT_F_DV_DECODER ` (MEDIA\_ENT\_F\_BASE + 0x6001) \#define \ :ref:`MEDIA_ENT_F_DV_ENCODER ` (MEDIA\_ENT\_F\_BASE + 0x6002) \/\* Entity flags \*\/ \#define \ :ref:`MEDIA_ENT_FL_DEFAULT ` (1U \<\< 0) \#define \ :ref:`MEDIA_ENT_FL_CONNECTOR ` (1U \<\< 1) \/\* OR with the entity id value to find the next entity \*\/ \#define \ :ref:`MEDIA_ENT_ID_FLAG_NEXT ` (1U \<\< 31) struct media_entity_desc \{ \_\_u32 id; char name[32]; \_\_u32 type; \_\_u32 revision; \_\_u32 flags; \_\_u32 group\_id; \_\_u16 pads; \_\_u16 links; \_\_u32 reserved[4]; union \{ \/\* Node specifications \*\/ struct \{ \_\_u32 major; \_\_u32 minor; \} dev; \#if !defined(\_\_KERNEL\_\_) \/\* \* TODO\: this shouldn't have been added without \* actual drivers that use this. When the first real driver \* appears that sets this information, special attention \* should be given whether this information is 1) enough, and \* 2) can deal with udev rules that rename devices. The struct \* dev would not be sufficient for this since that does not \* contain the subdevice information. In addition, struct dev \* can only refer to a single device, and not to multiple (e.g. \* pcm and mixer devices). \*\/ struct \{ \_\_u32 card; \_\_u32 device; \_\_u32 subdevice; \} alsa; \/\* \* **DEPRECATED**\: previous node specifications. Kept just to \* avoid breaking compilation. Use media\_entity\_desc.dev \* instead. \*\/ struct \{ \_\_u32 major; \_\_u32 minor; \} v4l; struct \{ \_\_u32 major; \_\_u32 minor; \} fb; int dvb; \#endif \/\* Sub-device specifications \*\/ \/\* Nothing needed yet \*\/ \_\_u8 raw[184]; \}; \}; \#define \ :ref:`MEDIA_PAD_FL_SINK ` (1U \<\< 0) \#define \ :ref:`MEDIA_PAD_FL_SOURCE ` (1U \<\< 1) \#define \ :ref:`MEDIA_PAD_FL_MUST_CONNECT ` (1U \<\< 2) struct media_pad_desc \{ \_\_u32 entity; \/\* entity ID \*\/ \_\_u16 index; \/\* pad index \*\/ \_\_u32 flags; \/\* pad flags \*\/ \_\_u32 reserved[2]; \}; \#define \ :ref:`MEDIA_LNK_FL_ENABLED ` (1U \<\< 0) \#define \ :ref:`MEDIA_LNK_FL_IMMUTABLE ` (1U \<\< 1) \#define \ :ref:`MEDIA_LNK_FL_DYNAMIC ` (1U \<\< 2) \#define \ :ref:`MEDIA_LNK_FL_LINK_TYPE ` (0xf \<\< 28) \# define \ :ref:`MEDIA_LNK_FL_DATA_LINK ` (0U \<\< 28) \# define \ :ref:`MEDIA_LNK_FL_INTERFACE_LINK ` (1U \<\< 28) \# define \ :ref:`MEDIA_LNK_FL_ANCILLARY_LINK ` (2U \<\< 28) struct media_link_desc \{ struct media_pad_desc source; struct media_pad_desc sink; \_\_u32 flags; \_\_u32 reserved[2]; \}; struct media_links_enum \{ \_\_u32 entity; \/\* Should have enough room for pads elements \*\/ struct media_pad_desc \_\_user \*pads; \/\* Should have enough room for links elements \*\/ struct media_link_desc \_\_user \*links; \_\_u32 reserved[4]; \}; \/\* Interface type ranges \*\/ \#define MEDIA\_INTF\_T\_DVB\_BASE 0x00000100 \#define MEDIA\_INTF\_T\_V4L\_BASE 0x00000200 \/\* Interface types \*\/ \#define \ :ref:`MEDIA_INTF_T_DVB_FE ` (MEDIA\_INTF\_T\_DVB\_BASE) \#define \ :ref:`MEDIA_INTF_T_DVB_DEMUX ` (MEDIA\_INTF\_T\_DVB\_BASE + 1) \#define \ :ref:`MEDIA_INTF_T_DVB_DVR ` (MEDIA\_INTF\_T\_DVB\_BASE + 2) \#define \ :ref:`MEDIA_INTF_T_DVB_CA ` (MEDIA\_INTF\_T\_DVB\_BASE + 3) \#define \ :ref:`MEDIA_INTF_T_DVB_NET ` (MEDIA\_INTF\_T\_DVB\_BASE + 4) \#define \ :ref:`MEDIA_INTF_T_V4L_VIDEO ` (MEDIA\_INTF\_T\_V4L\_BASE) \#define \ :ref:`MEDIA_INTF_T_V4L_VBI ` (MEDIA\_INTF\_T\_V4L\_BASE + 1) \#define \ :ref:`MEDIA_INTF_T_V4L_RADIO ` (MEDIA\_INTF\_T\_V4L\_BASE + 2) \#define \ :ref:`MEDIA_INTF_T_V4L_SUBDEV ` (MEDIA\_INTF\_T\_V4L\_BASE + 3) \#define \ :ref:`MEDIA_INTF_T_V4L_SWRADIO ` (MEDIA\_INTF\_T\_V4L\_BASE + 4) \#define \ :ref:`MEDIA_INTF_T_V4L_TOUCH ` (MEDIA\_INTF\_T\_V4L\_BASE + 5) \#define MEDIA\_INTF\_T\_ALSA\_BASE 0x00000300 \#define \ :ref:`MEDIA_INTF_T_ALSA_PCM_CAPTURE ` (MEDIA\_INTF\_T\_ALSA\_BASE) \#define \ :ref:`MEDIA_INTF_T_ALSA_PCM_PLAYBACK ` (MEDIA\_INTF\_T\_ALSA\_BASE + 1) \#define \ :ref:`MEDIA_INTF_T_ALSA_CONTROL ` (MEDIA\_INTF\_T\_ALSA\_BASE + 2) \#if defined(\_\_KERNEL\_\_) \/\* \* Connector functions \* \* For now these should not be used in userspace, as some definitions may \* change. \* \* It is the responsibility of the entity drivers to add connectors and links. \*\/ \#define \ :ref:`MEDIA_ENT_F_CONN_RF ` (MEDIA\_ENT\_F\_BASE + 0x30001) \#define \ :ref:`MEDIA_ENT_F_CONN_SVIDEO ` (MEDIA\_ENT\_F\_BASE + 0x30002) \#define \ :ref:`MEDIA_ENT_F_CONN_COMPOSITE ` (MEDIA\_ENT\_F\_BASE + 0x30003) \#endif \/\* \* MC next gen API definitions \*\/ \/\* \* Appeared in 4.19.0. \* \* The media\_version argument comes from the media\_version field in \* struct media\_device\_info. \*\/ \#define MEDIA\_V2\_ENTITY\_HAS\_FLAGS(media\_version) \\ ((media\_version) \>= ((4U \<\< 16) \| (19U \<\< 8) \| 0U)) struct media_v2_entity \{ \_\_u32 id; char name[64]; \_\_u32 function; \/\* Main function of the entity \*\/ \_\_u32 flags; \_\_u32 reserved[5]; \} \_\_attribute\_\_ ((packed)); \/\* Should match the specific fields at media\_intf\_devnode \*\/ struct media_v2_intf_devnode \{ \_\_u32 major; \_\_u32 minor; \} \_\_attribute\_\_ ((packed)); struct media_v2_interface \{ \_\_u32 id; \_\_u32 intf\_type; \_\_u32 flags; \_\_u32 reserved[9]; union \{ struct media_v2_intf_devnode devnode; \_\_u32 raw[16]; \}; \} \_\_attribute\_\_ ((packed)); \/\* \* Appeared in 4.19.0. \* \* The media\_version argument comes from the media\_version field in \* struct media\_device\_info. \*\/ \#define MEDIA\_V2\_PAD\_HAS\_INDEX(media\_version) \\ ((media\_version) \>= ((4U \<\< 16) \| (19U \<\< 8) \| 0U)) struct media_v2_pad \{ \_\_u32 id; \_\_u32 entity\_id; \_\_u32 flags; \_\_u32 index; \_\_u32 reserved[4]; \} \_\_attribute\_\_ ((packed)); struct media_v2_link \{ \_\_u32 id; \_\_u32 source\_id; \_\_u32 sink\_id; \_\_u32 flags; \_\_u32 reserved[6]; \} \_\_attribute\_\_ ((packed)); struct media_v2_topology \{ \_\_u64 topology\_version; \_\_u32 num\_entities; \_\_u32 reserved1; \_\_u64 ptr\_entities; \_\_u32 num\_interfaces; \_\_u32 reserved2; \_\_u64 ptr\_interfaces; \_\_u32 num\_pads; \_\_u32 reserved3; \_\_u64 ptr\_pads; \_\_u32 num\_links; \_\_u32 reserved4; \_\_u64 ptr\_links; \} \_\_attribute\_\_ ((packed)); \/\* ioctls \*\/ \#define \ :ref:`MEDIA_IOC_DEVICE_INFO ` \_IOWR('\|', 0x00, struct media_device_info\ ) \#define \ :ref:`MEDIA_IOC_ENUM_ENTITIES ` \_IOWR('\|', 0x01, struct media_entity_desc\ ) \#define \ :ref:`MEDIA_IOC_ENUM_LINKS ` \_IOWR('\|', 0x02, struct media_links_enum\ ) \#define \ :ref:`MEDIA_IOC_SETUP_LINK ` \_IOWR('\|', 0x03, struct media_link_desc\ ) \#define \ :ref:`MEDIA_IOC_G_TOPOLOGY ` \_IOWR('\|', 0x04, struct media_v2_topology\ ) \#define \ :ref:`MEDIA_IOC_REQUEST_ALLOC ` \_IOR ('\|', 0x05, int) \/\* \* These ioctls are called on the request file descriptor as returned \* by MEDIA\_IOC\_REQUEST\_ALLOC. \*\/ \#define \ :ref:`MEDIA_REQUEST_IOC_QUEUE ` \_IO('\|', 0x80) \#define \ :ref:`MEDIA_REQUEST_IOC_REINIT ` \_IO('\|', 0x81) \#ifndef \_\_KERNEL\_\_ \/\* \* Legacy symbols used to avoid userspace compilation breakages. \* Do not use any of this in new applications! \* \* Those symbols map the entity function into types and should be \* used only on legacy programs for legacy hardware. Don't rely \* on those for MEDIA\_IOC\_G\_TOPOLOGY. \*\/ \#define MEDIA\_ENT\_TYPE\_SHIFT 16 \#define MEDIA\_ENT\_TYPE\_MASK 0x00ff0000 \#define MEDIA\_ENT\_SUBTYPE\_MASK 0x0000ffff \#define MEDIA\_ENT\_T\_DEVNODE\_UNKNOWN (MEDIA\_ENT\_F\_OLD\_BASE \| \\ MEDIA\_ENT\_SUBTYPE\_MASK) \#define MEDIA\_ENT\_T\_DEVNODE MEDIA\_ENT\_F\_OLD\_BASE \#define MEDIA\_ENT\_T\_DEVNODE\_V4L \ :ref:`MEDIA_ENT_F_IO_V4L ` \#define MEDIA\_ENT\_T\_DEVNODE\_FB (MEDIA\_ENT\_F\_OLD\_BASE + 2) \#define MEDIA\_ENT\_T\_DEVNODE\_ALSA (MEDIA\_ENT\_F\_OLD\_BASE + 3) \#define MEDIA\_ENT\_T\_DEVNODE\_DVB (MEDIA\_ENT\_F\_OLD\_BASE + 4) \#define MEDIA\_ENT\_T\_UNKNOWN \ :ref:`MEDIA_ENT_F_UNKNOWN ` \#define MEDIA\_ENT\_T\_V4L2\_VIDEO \ :ref:`MEDIA_ENT_F_IO_V4L ` \#define MEDIA\_ENT\_T\_V4L2\_SUBDEV \ :ref:`MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ` \#define MEDIA\_ENT\_T\_V4L2\_SUBDEV\_SENSOR \ :ref:`MEDIA_ENT_F_CAM_SENSOR ` \#define MEDIA\_ENT\_T\_V4L2\_SUBDEV\_FLASH \ :ref:`MEDIA_ENT_F_FLASH ` \#define MEDIA\_ENT\_T\_V4L2\_SUBDEV\_LENS \ :ref:`MEDIA_ENT_F_LENS ` \#define MEDIA\_ENT\_T\_V4L2\_SUBDEV\_DECODER \ :ref:`MEDIA_ENT_F_ATV_DECODER ` \#define MEDIA\_ENT\_T\_V4L2\_SUBDEV\_TUNER \ :ref:`MEDIA_ENT_F_TUNER ` \#define MEDIA\_ENT\_F\_DTV\_DECODER \ :ref:`MEDIA_ENT_F_DV_DECODER ` \/\* \* There is still no full ALSA support in the media controller. These \* defines should not have been added and we leave them here only \* in case some application tries to use these defines. \* \* The ALSA defines that are in use have been moved into \_\_KERNEL\_\_ \* scope. As support gets added to these interface types, they should \* be moved into \_\_KERNEL\_\_ scope with the code that uses them. \*\/ \#define \ :ref:`MEDIA_INTF_T_ALSA_COMPRESS ` (MEDIA\_INTF\_T\_ALSA\_BASE + 3) \#define \ :ref:`MEDIA_INTF_T_ALSA_RAWMIDI ` (MEDIA\_INTF\_T\_ALSA\_BASE + 4) \#define \ :ref:`MEDIA_INTF_T_ALSA_HWDEP ` (MEDIA\_INTF\_T\_ALSA\_BASE + 5) \#define \ :ref:`MEDIA_INTF_T_ALSA_SEQUENCER ` (MEDIA\_INTF\_T\_ALSA\_BASE + 6) \#define \ :ref:`MEDIA_INTF_T_ALSA_TIMER ` (MEDIA\_INTF\_T\_ALSA\_BASE + 7) \/\* Obsolete symbol for media\_version, no longer used in the kernel \*\/ \#define MEDIA\_API\_VERSION ((0U \<\< 16) \| (1U \<\< 8) \| 0U) \#endif \#endif \/\* \_\_LINUX\_MEDIA\_H \*\/