diff options
Diffstat (limited to 'drivers/media/video/usbvision/usbvision-video.c')
-rw-r--r-- | drivers/media/video/usbvision/usbvision-video.c | 134 |
1 files changed, 89 insertions, 45 deletions
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index 31b133ef0698..8c7eba2a728e 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
@@ -204,7 +204,7 @@ MODULE_ALIAS(DRIVER_ALIAS); | |||
204 | 204 | ||
205 | static inline struct usb_usbvision *cd_to_usbvision(struct class_device *cd) | 205 | static inline struct usb_usbvision *cd_to_usbvision(struct class_device *cd) |
206 | { | 206 | { |
207 | struct video_device *vdev = to_video_device(cd); | 207 | struct video_device *vdev = container_of(cd, struct video_device, class_dev); |
208 | return video_get_drvdata(vdev); | 208 | return video_get_drvdata(vdev); |
209 | } | 209 | } |
210 | 210 | ||
@@ -214,81 +214,85 @@ static ssize_t show_version(struct class_device *cd, char *buf) | |||
214 | } | 214 | } |
215 | static CLASS_DEVICE_ATTR(version, S_IRUGO, show_version, NULL); | 215 | static CLASS_DEVICE_ATTR(version, S_IRUGO, show_version, NULL); |
216 | 216 | ||
217 | static ssize_t show_model(struct class_device *class_dev, char *buf) | 217 | static ssize_t show_model(struct class_device *cd, char *buf) |
218 | { | 218 | { |
219 | struct video_device *vdev = to_video_device(class_dev); | 219 | struct video_device *vdev = container_of(cd, struct video_device, class_dev); |
220 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 220 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
221 | return sprintf(buf, "%s\n", usbvision_device_data[usbvision->DevModel].ModelString); | 221 | return sprintf(buf, "%s\n", usbvision_device_data[usbvision->DevModel].ModelString); |
222 | } | 222 | } |
223 | static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL); | 223 | static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL); |
224 | 224 | ||
225 | static ssize_t show_hue(struct class_device *class_dev, char *buf) | 225 | static ssize_t show_hue(struct class_device *cd, char *buf) |
226 | { | 226 | { |
227 | struct video_device *vdev = to_video_device(class_dev); | 227 | struct video_device *vdev = container_of(cd, struct video_device, class_dev); |
228 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 228 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
229 | struct v4l2_control ctrl; | 229 | struct v4l2_control ctrl; |
230 | ctrl.id = V4L2_CID_HUE; | 230 | ctrl.id = V4L2_CID_HUE; |
231 | ctrl.value = 0; | 231 | ctrl.value = 0; |
232 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); | 232 | if(usbvision->user) |
233 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); | ||
233 | return sprintf(buf, "%d\n", ctrl.value >> 8); | 234 | return sprintf(buf, "%d\n", ctrl.value >> 8); |
234 | } | 235 | } |
235 | static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); | 236 | static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); |
236 | 237 | ||
237 | static ssize_t show_contrast(struct class_device *class_dev, char *buf) | 238 | static ssize_t show_contrast(struct class_device *cd, char *buf) |
238 | { | 239 | { |
239 | struct video_device *vdev = to_video_device(class_dev); | 240 | struct video_device *vdev = container_of(cd, struct video_device, class_dev); |
240 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 241 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
241 | struct v4l2_control ctrl; | 242 | struct v4l2_control ctrl; |
242 | ctrl.id = V4L2_CID_CONTRAST; | 243 | ctrl.id = V4L2_CID_CONTRAST; |
243 | ctrl.value = 0; | 244 | ctrl.value = 0; |
244 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); | 245 | if(usbvision->user) |
246 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); | ||
245 | return sprintf(buf, "%d\n", ctrl.value >> 8); | 247 | return sprintf(buf, "%d\n", ctrl.value >> 8); |
246 | } | 248 | } |
247 | static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); | 249 | static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); |
248 | 250 | ||
249 | static ssize_t show_brightness(struct class_device *class_dev, char *buf) | 251 | static ssize_t show_brightness(struct class_device *cd, char *buf) |
250 | { | 252 | { |
251 | struct video_device *vdev = to_video_device(class_dev); | 253 | struct video_device *vdev = container_of(cd, struct video_device, class_dev); |
252 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 254 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
253 | struct v4l2_control ctrl; | 255 | struct v4l2_control ctrl; |
254 | ctrl.id = V4L2_CID_BRIGHTNESS; | 256 | ctrl.id = V4L2_CID_BRIGHTNESS; |
255 | ctrl.value = 0; | 257 | ctrl.value = 0; |
256 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); | 258 | if(usbvision->user) |
259 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); | ||
257 | return sprintf(buf, "%d\n", ctrl.value >> 8); | 260 | return sprintf(buf, "%d\n", ctrl.value >> 8); |
258 | } | 261 | } |
259 | static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); | 262 | static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); |
260 | 263 | ||
261 | static ssize_t show_saturation(struct class_device *class_dev, char *buf) | 264 | static ssize_t show_saturation(struct class_device *cd, char *buf) |
262 | { | 265 | { |
263 | struct video_device *vdev = to_video_device(class_dev); | 266 | struct video_device *vdev = container_of(cd, struct video_device, class_dev); |
264 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 267 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
265 | struct v4l2_control ctrl; | 268 | struct v4l2_control ctrl; |
266 | ctrl.id = V4L2_CID_SATURATION; | 269 | ctrl.id = V4L2_CID_SATURATION; |
267 | ctrl.value = 0; | 270 | ctrl.value = 0; |
268 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); | 271 | if(usbvision->user) |
272 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); | ||
269 | return sprintf(buf, "%d\n", ctrl.value >> 8); | 273 | return sprintf(buf, "%d\n", ctrl.value >> 8); |
270 | } | 274 | } |
271 | static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); | 275 | static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); |
272 | 276 | ||
273 | static ssize_t show_streaming(struct class_device *class_dev, char *buf) | 277 | static ssize_t show_streaming(struct class_device *cd, char *buf) |
274 | { | 278 | { |
275 | struct video_device *vdev = to_video_device(class_dev); | 279 | struct video_device *vdev = container_of(cd, struct video_device, class_dev); |
276 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 280 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
277 | return sprintf(buf, "%s\n", YES_NO(usbvision->streaming==Stream_On?1:0)); | 281 | return sprintf(buf, "%s\n", YES_NO(usbvision->streaming==Stream_On?1:0)); |
278 | } | 282 | } |
279 | static CLASS_DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); | 283 | static CLASS_DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); |
280 | 284 | ||
281 | static ssize_t show_compression(struct class_device *class_dev, char *buf) | 285 | static ssize_t show_compression(struct class_device *cd, char *buf) |
282 | { | 286 | { |
283 | struct video_device *vdev = to_video_device(class_dev); | 287 | struct video_device *vdev = container_of(cd, struct video_device, class_dev); |
284 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 288 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
285 | return sprintf(buf, "%s\n", YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS)); | 289 | return sprintf(buf, "%s\n", YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS)); |
286 | } | 290 | } |
287 | static CLASS_DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); | 291 | static CLASS_DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); |
288 | 292 | ||
289 | static ssize_t show_device_bridge(struct class_device *class_dev, char *buf) | 293 | static ssize_t show_device_bridge(struct class_device *cd, char *buf) |
290 | { | 294 | { |
291 | struct video_device *vdev = to_video_device(class_dev); | 295 | struct video_device *vdev = container_of(cd, struct video_device, class_dev); |
292 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 296 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
293 | return sprintf(buf, "%d\n", usbvision->bridgeType); | 297 | return sprintf(buf, "%d\n", usbvision->bridgeType); |
294 | } | 298 | } |
@@ -297,31 +301,71 @@ static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL); | |||
297 | static void usbvision_create_sysfs(struct video_device *vdev) | 301 | static void usbvision_create_sysfs(struct video_device *vdev) |
298 | { | 302 | { |
299 | int res; | 303 | int res; |
300 | if (vdev) { | 304 | if (!vdev) |
301 | res=video_device_create_file(vdev, &class_device_attr_version); | 305 | return; |
302 | res=video_device_create_file(vdev, &class_device_attr_model); | 306 | do { |
303 | res=video_device_create_file(vdev, &class_device_attr_hue); | 307 | res=class_device_create_file(&vdev->class_dev, |
304 | res=video_device_create_file(vdev, &class_device_attr_contrast); | 308 | &class_device_attr_version); |
305 | res=video_device_create_file(vdev, &class_device_attr_brightness); | 309 | if (res<0) |
306 | res=video_device_create_file(vdev, &class_device_attr_saturation); | 310 | break; |
307 | res=video_device_create_file(vdev, &class_device_attr_streaming); | 311 | res=class_device_create_file(&vdev->class_dev, |
308 | res=video_device_create_file(vdev, &class_device_attr_compression); | 312 | &class_device_attr_model); |
309 | res=video_device_create_file(vdev, &class_device_attr_bridge); | 313 | if (res<0) |
310 | } | 314 | break; |
315 | res=class_device_create_file(&vdev->class_dev, | ||
316 | &class_device_attr_hue); | ||
317 | if (res<0) | ||
318 | break; | ||
319 | res=class_device_create_file(&vdev->class_dev, | ||
320 | &class_device_attr_contrast); | ||
321 | if (res<0) | ||
322 | break; | ||
323 | res=class_device_create_file(&vdev->class_dev, | ||
324 | &class_device_attr_brightness); | ||
325 | if (res<0) | ||
326 | break; | ||
327 | res=class_device_create_file(&vdev->class_dev, | ||
328 | &class_device_attr_saturation); | ||
329 | if (res<0) | ||
330 | break; | ||
331 | res=class_device_create_file(&vdev->class_dev, | ||
332 | &class_device_attr_streaming); | ||
333 | if (res<0) | ||
334 | break; | ||
335 | res=class_device_create_file(&vdev->class_dev, | ||
336 | &class_device_attr_compression); | ||
337 | if (res<0) | ||
338 | break; | ||
339 | res=class_device_create_file(&vdev->class_dev, | ||
340 | &class_device_attr_bridge); | ||
341 | if (res>=0) | ||
342 | return; | ||
343 | } while (0); | ||
344 | |||
345 | err("%s error: %d\n", __FUNCTION__, res); | ||
311 | } | 346 | } |
312 | 347 | ||
313 | static void usbvision_remove_sysfs(struct video_device *vdev) | 348 | static void usbvision_remove_sysfs(struct video_device *vdev) |
314 | { | 349 | { |
315 | if (vdev) { | 350 | if (vdev) { |
316 | video_device_remove_file(vdev, &class_device_attr_version); | 351 | class_device_remove_file(&vdev->class_dev, |
317 | video_device_remove_file(vdev, &class_device_attr_model); | 352 | &class_device_attr_version); |
318 | video_device_remove_file(vdev, &class_device_attr_hue); | 353 | class_device_remove_file(&vdev->class_dev, |
319 | video_device_remove_file(vdev, &class_device_attr_contrast); | 354 | &class_device_attr_model); |
320 | video_device_remove_file(vdev, &class_device_attr_brightness); | 355 | class_device_remove_file(&vdev->class_dev, |
321 | video_device_remove_file(vdev, &class_device_attr_saturation); | 356 | &class_device_attr_hue); |
322 | video_device_remove_file(vdev, &class_device_attr_streaming); | 357 | class_device_remove_file(&vdev->class_dev, |
323 | video_device_remove_file(vdev, &class_device_attr_compression); | 358 | &class_device_attr_contrast); |
324 | video_device_remove_file(vdev, &class_device_attr_bridge); | 359 | class_device_remove_file(&vdev->class_dev, |
360 | &class_device_attr_brightness); | ||
361 | class_device_remove_file(&vdev->class_dev, | ||
362 | &class_device_attr_saturation); | ||
363 | class_device_remove_file(&vdev->class_dev, | ||
364 | &class_device_attr_streaming); | ||
365 | class_device_remove_file(&vdev->class_dev, | ||
366 | &class_device_attr_compression); | ||
367 | class_device_remove_file(&vdev->class_dev, | ||
368 | &class_device_attr_bridge); | ||
325 | } | 369 | } |
326 | } | 370 | } |
327 | 371 | ||
@@ -1933,22 +1977,22 @@ static void customdevice_process(void) | |||
1933 | { | 1977 | { |
1934 | case 'P': | 1978 | case 'P': |
1935 | PDEBUG(DBG_PROBE, "VideoNorm=PAL"); | 1979 | PDEBUG(DBG_PROBE, "VideoNorm=PAL"); |
1936 | usbvision_device_data[0].VideoNorm=VIDEO_MODE_PAL; | 1980 | usbvision_device_data[0].VideoNorm=V4L2_STD_PAL; |
1937 | break; | 1981 | break; |
1938 | 1982 | ||
1939 | case 'S': | 1983 | case 'S': |
1940 | PDEBUG(DBG_PROBE, "VideoNorm=SECAM"); | 1984 | PDEBUG(DBG_PROBE, "VideoNorm=SECAM"); |
1941 | usbvision_device_data[0].VideoNorm=VIDEO_MODE_SECAM; | 1985 | usbvision_device_data[0].VideoNorm=V4L2_STD_SECAM; |
1942 | break; | 1986 | break; |
1943 | 1987 | ||
1944 | case 'N': | 1988 | case 'N': |
1945 | PDEBUG(DBG_PROBE, "VideoNorm=NTSC"); | 1989 | PDEBUG(DBG_PROBE, "VideoNorm=NTSC"); |
1946 | usbvision_device_data[0].VideoNorm=VIDEO_MODE_NTSC; | 1990 | usbvision_device_data[0].VideoNorm=V4L2_STD_NTSC; |
1947 | break; | 1991 | break; |
1948 | 1992 | ||
1949 | default: | 1993 | default: |
1950 | PDEBUG(DBG_PROBE, "VideoNorm=PAL (by default)"); | 1994 | PDEBUG(DBG_PROBE, "VideoNorm=PAL (by default)"); |
1951 | usbvision_device_data[0].VideoNorm=VIDEO_MODE_PAL; | 1995 | usbvision_device_data[0].VideoNorm=V4L2_STD_PAL; |
1952 | break; | 1996 | break; |
1953 | } | 1997 | } |
1954 | goto2next(parse); | 1998 | goto2next(parse); |