linux/include/uapi/linux/media.h

/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
 * Multimedia device API
 *
 * Copyright (C) 2010 Nokia Corporation
 *
 * Contacts: Laurent Pinchart <[email protected]>
 *	     Sakari Ailus <[email protected]>
 *
 * 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 <linux/ioctl.h>
#include <linux/types.h>

struct media_device_info {};

/*
 * 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
#define MEDIA_ENT_F_OLD_BASE
#define MEDIA_ENT_F_OLD_SUBDEV_BASE

/*
 * Initial value to be used when a new entity is created
 * Drivers should change it to something useful.
 */
#define MEDIA_ENT_F_UNKNOWN

/*
 * Subdevs are initialized with 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 MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN

/*
 * DVB entity functions
 */
#define MEDIA_ENT_F_DTV_DEMOD
#define MEDIA_ENT_F_TS_DEMUX
#define MEDIA_ENT_F_DTV_CA
#define MEDIA_ENT_F_DTV_NET_DECAP

/*
 * I/O entity functions
 */
#define MEDIA_ENT_F_IO_V4L
#define MEDIA_ENT_F_IO_DTV
#define MEDIA_ENT_F_IO_VBI
#define MEDIA_ENT_F_IO_SWRADIO

/*
 * Sensor functions
 */
#define MEDIA_ENT_F_CAM_SENSOR
#define MEDIA_ENT_F_FLASH
#define MEDIA_ENT_F_LENS

/*
 * 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:
 * MEDIA_ENT_F_IF_VID_DECODER and/or MEDIA_ENT_F_IF_AUD_DECODER.
 */
#define MEDIA_ENT_F_TUNER

/*
 * Analog TV IF-PLL decoder functions
 *
 * It is a responsibility of the master/bridge drivers to create links
 * for MEDIA_ENT_F_IF_VID_DECODER and MEDIA_ENT_F_IF_AUD_DECODER.
 */
#define MEDIA_ENT_F_IF_VID_DECODER
#define MEDIA_ENT_F_IF_AUD_DECODER

/*
 * Audio entity functions
 */
#define MEDIA_ENT_F_AUDIO_CAPTURE
#define MEDIA_ENT_F_AUDIO_PLAYBACK
#define MEDIA_ENT_F_AUDIO_MIXER

/*
 * Processing entity functions
 */
#define MEDIA_ENT_F_PROC_VIDEO_COMPOSER
#define MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER
#define MEDIA_ENT_F_PROC_VIDEO_PIXEL_ENC_CONV
#define MEDIA_ENT_F_PROC_VIDEO_LUT
#define MEDIA_ENT_F_PROC_VIDEO_SCALER
#define MEDIA_ENT_F_PROC_VIDEO_STATISTICS
#define MEDIA_ENT_F_PROC_VIDEO_ENCODER
#define MEDIA_ENT_F_PROC_VIDEO_DECODER
#define MEDIA_ENT_F_PROC_VIDEO_ISP

/*
 * Switch and bridge entity functions
 */
#define MEDIA_ENT_F_VID_MUX
#define MEDIA_ENT_F_VID_IF_BRIDGE

/*
 * Video decoder/encoder functions
 */
#define MEDIA_ENT_F_ATV_DECODER
#define MEDIA_ENT_F_DV_DECODER
#define MEDIA_ENT_F_DV_ENCODER

/* Entity flags */
#define MEDIA_ENT_FL_DEFAULT
#define MEDIA_ENT_FL_CONNECTOR

/* OR with the entity id value to find the next entity */
#define MEDIA_ENT_ID_FLAG_NEXT

struct media_entity_desc {};

#define MEDIA_PAD_FL_SINK
#define MEDIA_PAD_FL_SOURCE
#define MEDIA_PAD_FL_MUST_CONNECT

struct media_pad_desc {};

#define MEDIA_LNK_FL_ENABLED
#define MEDIA_LNK_FL_IMMUTABLE
#define MEDIA_LNK_FL_DYNAMIC

#define MEDIA_LNK_FL_LINK_TYPE
#define MEDIA_LNK_FL_DATA_LINK
#define MEDIA_LNK_FL_INTERFACE_LINK
#define MEDIA_LNK_FL_ANCILLARY_LINK

struct media_link_desc {};

struct media_links_enum {};

/* Interface type ranges */

#define MEDIA_INTF_T_DVB_BASE
#define MEDIA_INTF_T_V4L_BASE

/* Interface types */

#define MEDIA_INTF_T_DVB_FE
#define MEDIA_INTF_T_DVB_DEMUX
#define MEDIA_INTF_T_DVB_DVR
#define MEDIA_INTF_T_DVB_CA
#define MEDIA_INTF_T_DVB_NET

#define MEDIA_INTF_T_V4L_VIDEO
#define MEDIA_INTF_T_V4L_VBI
#define MEDIA_INTF_T_V4L_RADIO
#define MEDIA_INTF_T_V4L_SUBDEV
#define MEDIA_INTF_T_V4L_SWRADIO
#define MEDIA_INTF_T_V4L_TOUCH

#define MEDIA_INTF_T_ALSA_BASE
#define MEDIA_INTF_T_ALSA_PCM_CAPTURE
#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK
#define MEDIA_INTF_T_ALSA_CONTROL

#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 MEDIA_ENT_F_CONN_RF
#define MEDIA_ENT_F_CONN_SVIDEO
#define MEDIA_ENT_F_CONN_COMPOSITE

#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)

struct media_v2_entity {} __attribute__ ((packed));

/* Should match the specific fields at media_intf_devnode */
struct media_v2_intf_devnode {} __attribute__ ((packed));

struct media_v2_interface {} __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)

struct media_v2_pad {} __attribute__ ((packed));

struct media_v2_link {} __attribute__ ((packed));

struct media_v2_topology {} __attribute__ ((packed));

/* ioctls */

#define MEDIA_IOC_DEVICE_INFO
#define MEDIA_IOC_ENUM_ENTITIES
#define MEDIA_IOC_ENUM_LINKS
#define MEDIA_IOC_SETUP_LINK
#define MEDIA_IOC_G_TOPOLOGY
#define MEDIA_IOC_REQUEST_ALLOC

/*
 * These ioctls are called on the request file descriptor as returned
 * by MEDIA_IOC_REQUEST_ALLOC.
 */
#define MEDIA_REQUEST_IOC_QUEUE
#define MEDIA_REQUEST_IOC_REINIT

#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
#define MEDIA_ENT_TYPE_MASK
#define MEDIA_ENT_SUBTYPE_MASK

#define MEDIA_ENT_T_DEVNODE_UNKNOWN

#define MEDIA_ENT_T_DEVNODE
#define MEDIA_ENT_T_DEVNODE_V4L
#define MEDIA_ENT_T_DEVNODE_FB
#define MEDIA_ENT_T_DEVNODE_ALSA
#define MEDIA_ENT_T_DEVNODE_DVB

#define MEDIA_ENT_T_UNKNOWN
#define MEDIA_ENT_T_V4L2_VIDEO
#define MEDIA_ENT_T_V4L2_SUBDEV
#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR
#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH
#define MEDIA_ENT_T_V4L2_SUBDEV_LENS
#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER
#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER

#define MEDIA_ENT_F_DTV_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 MEDIA_INTF_T_ALSA_COMPRESS
#define MEDIA_INTF_T_ALSA_RAWMIDI
#define MEDIA_INTF_T_ALSA_HWDEP
#define MEDIA_INTF_T_ALSA_SEQUENCER
#define MEDIA_INTF_T_ALSA_TIMER

/* Obsolete symbol for media_version, no longer used in the kernel */
#define MEDIA_API_VERSION

#endif

#endif /* __LINUX_MEDIA_H */