• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     V4L2 sub-device support.
3 
4     Copyright (C) 2008  Hans Verkuil <hverkuil@xs4all.nl>
5 
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10 
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 
21 #include <linux/types.h>
22 #include <linux/ioctl.h>
23 #include <linux/i2c.h>
24 #include <linux/videodev2.h>
25 #include <media/v4l2-subdev.h>
26 
v4l2_subdev_command(struct v4l2_subdev * sd,unsigned cmd,void * arg)27 int v4l2_subdev_command(struct v4l2_subdev *sd, unsigned cmd, void *arg)
28 {
29 	switch (cmd) {
30 	case VIDIOC_QUERYCTRL:
31 		return v4l2_subdev_call(sd, core, queryctrl, arg);
32 	case VIDIOC_G_CTRL:
33 		return v4l2_subdev_call(sd, core, g_ctrl, arg);
34 	case VIDIOC_S_CTRL:
35 		return v4l2_subdev_call(sd, core, s_ctrl, arg);
36 	case VIDIOC_QUERYMENU:
37 		return v4l2_subdev_call(sd, core, querymenu, arg);
38 	case VIDIOC_LOG_STATUS:
39 		return v4l2_subdev_call(sd, core, log_status);
40 	case VIDIOC_DBG_G_CHIP_IDENT:
41 		return v4l2_subdev_call(sd, core, g_chip_ident, arg);
42 	case VIDIOC_INT_S_STANDBY:
43 		return v4l2_subdev_call(sd, core, s_standby, arg ? (*(u32 *)arg) : 0);
44 	case VIDIOC_INT_RESET:
45 		return v4l2_subdev_call(sd, core, reset, arg ? (*(u32 *)arg) : 0);
46 	case VIDIOC_INT_S_GPIO:
47 		return v4l2_subdev_call(sd, core, s_gpio, arg ? (*(u32 *)arg) : 0);
48 	case VIDIOC_INT_INIT:
49 		return v4l2_subdev_call(sd, core, init, arg ? (*(u32 *)arg) : 0);
50 #ifdef CONFIG_VIDEO_ADV_DEBUG
51 	case VIDIOC_DBG_G_REGISTER:
52 		return v4l2_subdev_call(sd, core, g_register, arg);
53 	case VIDIOC_DBG_S_REGISTER:
54 		return v4l2_subdev_call(sd, core, s_register, arg);
55 #endif
56 
57 	case VIDIOC_INT_S_TUNER_MODE:
58 		return v4l2_subdev_call(sd, tuner, s_mode, *(enum v4l2_tuner_type *)arg);
59 	case AUDC_SET_RADIO:
60 		return v4l2_subdev_call(sd, tuner, s_radio);
61 	case VIDIOC_S_TUNER:
62 		return v4l2_subdev_call(sd, tuner, s_tuner, arg);
63 	case VIDIOC_G_TUNER:
64 		return v4l2_subdev_call(sd, tuner, g_tuner, arg);
65 	case VIDIOC_S_STD:
66 		return v4l2_subdev_call(sd, tuner, s_std, *(v4l2_std_id *)arg);
67 	case VIDIOC_S_FREQUENCY:
68 		return v4l2_subdev_call(sd, tuner, s_frequency, arg);
69 	case VIDIOC_G_FREQUENCY:
70 		return v4l2_subdev_call(sd, tuner, g_frequency, arg);
71 	case TUNER_SET_TYPE_ADDR:
72 		return v4l2_subdev_call(sd, tuner, s_type_addr, arg);
73 	case TUNER_SET_CONFIG:
74 		return v4l2_subdev_call(sd, tuner, s_config, arg);
75 
76 	case VIDIOC_INT_AUDIO_CLOCK_FREQ:
77 		return v4l2_subdev_call(sd, audio, s_clock_freq, *(u32 *)arg);
78 	case VIDIOC_INT_S_AUDIO_ROUTING:
79 		return v4l2_subdev_call(sd, audio, s_routing, arg);
80 	case VIDIOC_INT_I2S_CLOCK_FREQ:
81 		return v4l2_subdev_call(sd, audio, s_i2s_clock_freq, *(u32 *)arg);
82 
83 	case VIDIOC_INT_S_VIDEO_ROUTING:
84 		return v4l2_subdev_call(sd, video, s_routing, arg);
85 	case VIDIOC_INT_S_CRYSTAL_FREQ:
86 		return v4l2_subdev_call(sd, video, s_crystal_freq, arg);
87 	case VIDIOC_INT_DECODE_VBI_LINE:
88 		return v4l2_subdev_call(sd, video, decode_vbi_line, arg);
89 	case VIDIOC_INT_S_VBI_DATA:
90 		return v4l2_subdev_call(sd, video, s_vbi_data, arg);
91 	case VIDIOC_INT_G_VBI_DATA:
92 		return v4l2_subdev_call(sd, video, g_vbi_data, arg);
93 	case VIDIOC_G_SLICED_VBI_CAP:
94 		return v4l2_subdev_call(sd, video, g_sliced_vbi_cap, arg);
95 	case VIDIOC_S_FMT:
96 		return v4l2_subdev_call(sd, video, s_fmt, arg);
97 	case VIDIOC_G_FMT:
98 		return v4l2_subdev_call(sd, video, g_fmt, arg);
99 	case VIDIOC_INT_S_STD_OUTPUT:
100 		return v4l2_subdev_call(sd, video, s_std_output, *(v4l2_std_id *)arg);
101 	case VIDIOC_STREAMON:
102 		return v4l2_subdev_call(sd, video, s_stream, 1);
103 	case VIDIOC_STREAMOFF:
104 		return v4l2_subdev_call(sd, video, s_stream, 0);
105 
106 	default:
107 		return v4l2_subdev_call(sd, core, ioctl, cmd, arg);
108 	}
109 }
110 EXPORT_SYMBOL_GPL(v4l2_subdev_command);
111