Lines Matching +full:0 +full:- +full:dev

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Hauppauge HD PVR USB driver - video 4 linux 2 interface
18 #include <media/v4l2-common.h>
23 int hdpvr_config_call(struct hdpvr_device *dev, uint value, u8 valbuf) in hdpvr_config_call() argument
26 char request_type = 0x38, snd_request = 0x01; in hdpvr_config_call()
28 mutex_lock(&dev->usbc_mutex); in hdpvr_config_call()
29 dev->usbc_buf[0] = valbuf; in hdpvr_config_call()
30 ret = usb_control_msg(dev->udev, in hdpvr_config_call()
31 usb_sndctrlpipe(dev->udev, 0), in hdpvr_config_call()
32 snd_request, 0x00 | request_type, in hdpvr_config_call()
34 dev->usbc_buf, 1, 10000); in hdpvr_config_call()
36 mutex_unlock(&dev->usbc_mutex); in hdpvr_config_call()
37 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in hdpvr_config_call()
38 "config call request for value 0x%x returned %d\n", value, in hdpvr_config_call()
41 return ret < 0 ? ret : 0; in hdpvr_config_call()
44 int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vidinf) in get_video_info() argument
48 vidinf->valid = false; in get_video_info()
49 mutex_lock(&dev->usbc_mutex); in get_video_info()
50 ret = usb_control_msg(dev->udev, in get_video_info()
51 usb_rcvctrlpipe(dev->udev, 0), in get_video_info()
52 0x81, 0x80 | 0x38, in get_video_info()
53 0x1400, 0x0003, in get_video_info()
54 dev->usbc_buf, 5, in get_video_info()
59 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in get_video_info()
61 dev->usbc_buf); in get_video_info()
63 mutex_unlock(&dev->usbc_mutex); in get_video_info()
65 if (ret < 0) in get_video_info()
68 vidinf->width = dev->usbc_buf[1] << 8 | dev->usbc_buf[0]; in get_video_info()
69 vidinf->height = dev->usbc_buf[3] << 8 | dev->usbc_buf[2]; in get_video_info()
70 vidinf->fps = dev->usbc_buf[4]; in get_video_info()
71 vidinf->valid = vidinf->width && vidinf->height && vidinf->fps; in get_video_info()
73 return 0; in get_video_info()
76 int get_input_lines_info(struct hdpvr_device *dev) in get_input_lines_info() argument
80 mutex_lock(&dev->usbc_mutex); in get_input_lines_info()
81 ret = usb_control_msg(dev->udev, in get_input_lines_info()
82 usb_rcvctrlpipe(dev->udev, 0), in get_input_lines_info()
83 0x81, 0x80 | 0x38, in get_input_lines_info()
84 0x1800, 0x0003, in get_input_lines_info()
85 dev->usbc_buf, 3, in get_input_lines_info()
90 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, in get_input_lines_info()
92 dev->usbc_buf); in get_input_lines_info()
96 lines = dev->usbc_buf[1] << 8 | dev->usbc_buf[0]; in get_input_lines_info()
97 mutex_unlock(&dev->usbc_mutex); in get_input_lines_info()
102 int hdpvr_set_bitrate(struct hdpvr_device *dev) in hdpvr_set_bitrate() argument
106 mutex_lock(&dev->usbc_mutex); in hdpvr_set_bitrate()
107 memset(dev->usbc_buf, 0, 4); in hdpvr_set_bitrate()
108 dev->usbc_buf[0] = dev->options.bitrate; in hdpvr_set_bitrate()
109 dev->usbc_buf[2] = dev->options.peak_bitrate; in hdpvr_set_bitrate()
111 ret = usb_control_msg(dev->udev, in hdpvr_set_bitrate()
112 usb_sndctrlpipe(dev->udev, 0), in hdpvr_set_bitrate()
113 0x01, 0x38, CTRL_BITRATE_VALUE, in hdpvr_set_bitrate()
114 CTRL_DEFAULT_INDEX, dev->usbc_buf, 4, 1000); in hdpvr_set_bitrate()
115 mutex_unlock(&dev->usbc_mutex); in hdpvr_set_bitrate()
120 int hdpvr_set_audio(struct hdpvr_device *dev, u8 input, in hdpvr_set_audio() argument
123 int ret = 0; in hdpvr_set_audio()
125 if (dev->flags & HDPVR_FLAG_AC3_CAP) { in hdpvr_set_audio()
126 mutex_lock(&dev->usbc_mutex); in hdpvr_set_audio()
127 memset(dev->usbc_buf, 0, 2); in hdpvr_set_audio()
128 dev->usbc_buf[0] = input; in hdpvr_set_audio()
130 dev->usbc_buf[1] = 0; in hdpvr_set_audio()
132 dev->usbc_buf[1] = 1; in hdpvr_set_audio()
134 mutex_unlock(&dev->usbc_mutex); in hdpvr_set_audio()
135 v4l2_err(&dev->v4l2_dev, "invalid audio codec %d\n", in hdpvr_set_audio()
137 ret = -EINVAL; in hdpvr_set_audio()
141 ret = usb_control_msg(dev->udev, in hdpvr_set_audio()
142 usb_sndctrlpipe(dev->udev, 0), in hdpvr_set_audio()
143 0x01, 0x38, CTRL_AUDIO_INPUT_VALUE, in hdpvr_set_audio()
144 CTRL_DEFAULT_INDEX, dev->usbc_buf, 2, in hdpvr_set_audio()
146 mutex_unlock(&dev->usbc_mutex); in hdpvr_set_audio()
148 ret = 0; in hdpvr_set_audio()
150 ret = hdpvr_config_call(dev, CTRL_AUDIO_INPUT_VALUE, input); in hdpvr_set_audio()
155 int hdpvr_set_options(struct hdpvr_device *dev) in hdpvr_set_options() argument
157 hdpvr_config_call(dev, CTRL_VIDEO_STD_TYPE, dev->options.video_std); in hdpvr_set_options()
159 hdpvr_config_call(dev, CTRL_VIDEO_INPUT_VALUE, in hdpvr_set_options()
160 dev->options.video_input+1); in hdpvr_set_options()
162 hdpvr_set_audio(dev, dev->options.audio_input+1, in hdpvr_set_options()
163 dev->options.audio_codec); in hdpvr_set_options()
165 hdpvr_set_bitrate(dev); in hdpvr_set_options()
166 hdpvr_config_call(dev, CTRL_BITRATE_MODE_VALUE, in hdpvr_set_options()
167 dev->options.bitrate_mode); in hdpvr_set_options()
168 hdpvr_config_call(dev, CTRL_GOP_MODE_VALUE, dev->options.gop_mode); in hdpvr_set_options()
170 hdpvr_config_call(dev, CTRL_BRIGHTNESS, dev->options.brightness); in hdpvr_set_options()
171 hdpvr_config_call(dev, CTRL_CONTRAST, dev->options.contrast); in hdpvr_set_options()
172 hdpvr_config_call(dev, CTRL_HUE, dev->options.hue); in hdpvr_set_options()
173 hdpvr_config_call(dev, CTRL_SATURATION, dev->options.saturation); in hdpvr_set_options()
174 hdpvr_config_call(dev, CTRL_SHARPNESS, dev->options.sharpness); in hdpvr_set_options()
176 return 0; in hdpvr_set_options()