media: dvbdev: convert DVB device types into an enum

Enums can be documented via kernel-doc. So, convert the
DVB_DEVICE_* macros to an enum.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
Mauro Carvalho Chehab 2017-09-19 14:22:19 -04:00
parent 259a41d9ae
commit 6bbf7a855d
2 changed files with 64 additions and 21 deletions

View File

@ -51,8 +51,15 @@ static LIST_HEAD(dvb_adapter_list);
static DEFINE_MUTEX(dvbdev_register_lock); static DEFINE_MUTEX(dvbdev_register_lock);
static const char * const dnames[] = { static const char * const dnames[] = {
"video", "audio", "sec", "frontend", "demux", "dvr", "ca", [DVB_DEVICE_VIDEO] = "video",
"net", "osd" [DVB_DEVICE_AUDIO] = "audio",
[DVB_DEVICE_SEC] = "sec",
[DVB_DEVICE_FRONTEND] = "frontend",
[DVB_DEVICE_DEMUX] = "demux",
[DVB_DEVICE_DVR] = "dvr",
[DVB_DEVICE_CA] = "ca",
[DVB_DEVICE_NET] = "net",
[DVB_DEVICE_OSD] = "osd"
}; };
#ifdef CONFIG_DVB_DYNAMIC_MINORS #ifdef CONFIG_DVB_DYNAMIC_MINORS
@ -60,7 +67,24 @@ static const char * const dnames[] = {
#define DVB_MAX_IDS MAX_DVB_MINORS #define DVB_MAX_IDS MAX_DVB_MINORS
#else #else
#define DVB_MAX_IDS 4 #define DVB_MAX_IDS 4
#define nums2minor(num, type, id) ((num << 6) | (id << 4) | type)
static int nums2minor(int num, enum dvb_device_type type, int id)
{
int n = (num << 6) | (id << 4);
switch (type) {
case DVB_DEVICE_VIDEO: return n;
case DVB_DEVICE_AUDIO: return n | 1;
case DVB_DEVICE_SEC: return n | 2;
case DVB_DEVICE_FRONTEND: return n | 3;
case DVB_DEVICE_DEMUX: return n | 4;
case DVB_DEVICE_DVR: return n | 5;
case DVB_DEVICE_CA: return n | 6;
case DVB_DEVICE_NET: return n | 7;
case DVB_DEVICE_OSD: return n | 8;
}
}
#define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64) #define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64)
#endif #endif
@ -426,8 +450,8 @@ static int dvb_register_media_device(struct dvb_device *dvbdev,
} }
int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
const struct dvb_device *template, void *priv, int type, const struct dvb_device *template, void *priv,
int demux_sink_pads) enum dvb_device_type type, int demux_sink_pads)
{ {
struct dvb_device *dvbdev; struct dvb_device *dvbdev;
struct file_operations *dvbdevfops; struct file_operations *dvbdevfops;

View File

@ -35,15 +35,37 @@
#define DVB_UNSET (-1) #define DVB_UNSET (-1)
#define DVB_DEVICE_VIDEO 0 /* List of DVB device types */
#define DVB_DEVICE_AUDIO 1
#define DVB_DEVICE_SEC 2 /**
#define DVB_DEVICE_FRONTEND 3 * enum dvb_device_type - type of the Digital TV device
#define DVB_DEVICE_DEMUX 4 *
#define DVB_DEVICE_DVR 5 * @DVB_DEVICE_SEC: Digital TV standalone Common Interface (CI)
#define DVB_DEVICE_CA 6 * @DVB_DEVICE_FRONTEND: Digital TV frontend.
#define DVB_DEVICE_NET 7 * @DVB_DEVICE_DEMUX: Digital TV demux.
#define DVB_DEVICE_OSD 8 * @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) \ #define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \
static short adapter_nr[] = \ static short adapter_nr[] = \
@ -104,8 +126,7 @@ struct dvb_adapter {
* @list_head: List head with all DVB devices * @list_head: List head with all DVB devices
* @fops: pointer to struct file_operations * @fops: pointer to struct file_operations
* @adapter: pointer to the adapter that holds this device node * @adapter: pointer to the adapter that holds this device node
* @type: type of the device: DVB_DEVICE_SEC, DVB_DEVICE_FRONTEND, * @type: type of the device, as defined by &enum dvb_device_type.
* DVB_DEVICE_DEMUX, DVB_DEVICE_DVR, DVB_DEVICE_CA, DVB_DEVICE_NET
* @minor: devnode minor number. Major number is always DVB_MAJOR. * @minor: devnode minor number. Major number is always DVB_MAJOR.
* @id: device ID number, inside the adapter * @id: device ID number, inside the adapter
* @readers: Initialized by the caller. Each call to open() in Read Only mode * @readers: Initialized by the caller. Each call to open() in Read Only mode
@ -135,7 +156,7 @@ struct dvb_device {
struct list_head list_head; struct list_head list_head;
const struct file_operations *fops; const struct file_operations *fops;
struct dvb_adapter *adapter; struct dvb_adapter *adapter;
int type; enum dvb_device_type type;
int minor; int minor;
u32 id; u32 id;
@ -194,9 +215,7 @@ int dvb_unregister_adapter(struct dvb_adapter *adap);
* stored * stored
* @template: Template used to create &pdvbdev; * @template: Template used to create &pdvbdev;
* @priv: private data * @priv: private data
* @type: type of the device: %DVB_DEVICE_SEC, %DVB_DEVICE_FRONTEND, * @type: type of the device, as defined by &enum dvb_device_type.
* %DVB_DEVICE_DEMUX, %DVB_DEVICE_DVR, %DVB_DEVICE_CA,
* %DVB_DEVICE_NET
* @demux_sink_pads: Number of demux outputs, to be used to create the TS * @demux_sink_pads: Number of demux outputs, to be used to create the TS
* outputs via the Media Controller. * outputs via the Media Controller.
*/ */
@ -204,7 +223,7 @@ int dvb_register_device(struct dvb_adapter *adap,
struct dvb_device **pdvbdev, struct dvb_device **pdvbdev,
const struct dvb_device *template, const struct dvb_device *template,
void *priv, void *priv,
int type, enum dvb_device_type type,
int demux_sink_pads); int demux_sink_pads);
/** /**