• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2    Copyright © 2011 by Mauro Carvalho Chehab
3 
4    The get_media_devices is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8 
9    The libv4l2util Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13 
14    You should have received a copy of the GNU Lesser General Public
15    License along with the libv4l2util Library; if not, write to the Free
16    Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA
17    02110-1335 USA.
18  */
19 
20 /*
21  * Version of the API
22  */
23 #define GET_MEDIA_DEVICES_VERSION	0x0105
24 
25 /**
26  * enum device_type - Enumerates the type for each device
27  *
28  * The device_type is used to sort the media devices array.
29  * So, the order is relevant. The first device should be
30  * MEDIA_V4L_VIDEO.
31  */
32 enum device_type {
33 	UNKNOWN = 65535,
34 	NONE    = 65534,
35 	MEDIA_V4L_VIDEO = 0,
36 	MEDIA_V4L_VBI,
37 	MEDIA_V4L_RADIO,
38 	MEDIA_V4L_SWRADIO,
39 	MEDIA_V4L_TOUCH,
40 	MEDIA_V4L_SUBDEV,
41 
42 	MEDIA_DVB_VIDEO = 100,
43 	MEDIA_DVB_AUDIO,
44 	MEDIA_DVB_SEC,
45 	MEDIA_DVB_FRONTEND,
46 	MEDIA_DVB_DEMUX,
47 	MEDIA_DVB_DVR,
48 	MEDIA_DVB_CA,
49 	MEDIA_DVB_NET,
50 	MEDIA_DVB_OSD,
51 
52 	MEDIA_SND_CARD = 200,
53 	MEDIA_SND_CAP,
54 	MEDIA_SND_OUT,
55 	MEDIA_SND_CONTROL,
56 	MEDIA_SND_HW,
57 	MEDIA_SND_TIMER,
58 	MEDIA_SND_SEQ,
59 	/*
60 	 * FIXME: not all alsa devices were mapped. missing things like
61 	 *	midi, midiC%iD%i and timer interfaces
62 	 */
63 };
64 
65 enum bus_type {
66 	MEDIA_BUS_UNKNOWN,
67 	MEDIA_BUS_VIRTUAL,
68 	MEDIA_BUS_PCI,
69 	MEDIA_BUS_USB,
70 };
71 
72 /**
73  * discover_media_devices() - Returns a list of the media devices
74  * @md_size:	Returns the size of the media devices found
75  *
76  * This function reads the /sys/class nodes for V4L, DVB and sound,
77  * and returns an opaque desciptor that keeps a list of the devices.
78  * The fields on this list is opaque, as they can be changed on newer
79  * releases of this library. So, all access to it should be done via
80  * a function provided by the API. The devices are ordered by device,
81  * type and node. At return, md_size is updated.
82  */
83 void *discover_media_devices(void);
84 
85 /**
86  * free_media_devices() - Frees the media devices array
87  *
88  * @opaque:	media devices opaque descriptor
89  *
90  * As discover_media_devices() dynamically allocate space for the
91  * strings, feeing the list requires also to free those data. So,
92  * the safest and recommended way is to call this function.
93  */
94 void free_media_devices(void *opaque);
95 
96 /**
97  * media_device_type() - returns a string with the name of a given type
98  *
99  * @type:	media device type
100  */
101 const char *media_device_type(const enum device_type type);
102 
103 /**
104  * display_media_devices() - prints a list of media devices
105  *
106  * @opaque:	media devices opaque descriptor
107  */
108 void display_media_devices(void *opaque);
109 
110 /**
111  * get_associated_device() - Return the next device associated with another one
112  *
113  * @opaque:		media devices opaque descriptor
114  * @last_seek:		last seek result. Use NULL to get the first result
115  * @desired_type:	type of the desired device
116  * @seek_device:	name of the device with you want to get an association.
117  *@ seek_type:		type of the seek device. Using NONE produces the same
118  *			result of using NULL for the seek_device.
119  *
120  * This function seeks inside the media_devices struct for the next device
121  * that it is associated with a seek parameter.
122  * It can be used to get an alsa device associated with a video device. If
123  * the seek_device is NULL or seek_type is NONE, it will just search for
124  * devices of the desired_type.
125  */
126 const char *get_associated_device(void *opaque,
127 				  const char *last_seek,
128 				  const enum device_type desired_type,
129 				  const char *seek_device,
130 				  const enum device_type seek_type);
131 
132 /**
133  * fget_associated_device() - Return the next device associated with another one
134  *
135  * @opaque:		media devices opaque descriptor
136  * @last_seek:		last seek result. Use NULL to get the first result
137  * @desired_type:	type of the desired device
138  * @fd_seek_device:	file handler for the device where the association will
139 			be made
140  *@ seek_type:		type of the seek device. Using NONE produces the same
141  *			result of using NULL for the seek_device.
142  *
143  * This function seeks inside the media_devices struct for the next device
144  * that it is associated with a seek parameter.
145  * It can be used to get an alsa device associated with an open file descriptor
146  */
147 const char *fget_associated_device(void *opaque,
148 				   const char *last_seek,
149 				   const enum device_type desired_type,
150 				   const int fd_seek_device,
151 				   const enum device_type seek_type);
152 
153 /**
154  * get_not_associated_device() - Return the next device not associated with
155  *			     an specific device type.
156  *
157  * @opaque:		media devices opaque descriptor
158  * @last_seek:		last seek result. Use NULL to get the first result
159  * @desired_type:	type of the desired device
160  * @not_desired_type:	type of the seek device
161  *
162  * This function seeks inside the media_devices struct for the next physical
163  * device that doesn't support a non_desired type.
164  * This method is useful for example to return the audio devices that are
165  * provided by the motherboard.
166  */
167 const char *get_not_associated_device(void *opaque,
168 				      const char *last_seek,
169 				      const enum device_type desired_type,
170 				      const enum device_type not_desired_type);
171