Lines Matching refs:pdev
150 int pwc_init_controls(struct pwc_device *pdev) in pwc_init_controls() argument
156 hdl = &pdev->ctrl_handler; in pwc_init_controls()
162 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, BRIGHTNESS_FORMATTER, &def); in pwc_init_controls()
165 pdev->brightness = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
168 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, CONTRAST_FORMATTER, &def); in pwc_init_controls()
171 pdev->contrast = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
174 if (pdev->type >= 675) { in pwc_init_controls()
175 if (pdev->type < 730) in pwc_init_controls()
176 pdev->saturation_fmt = SATURATION_MODE_FORMATTER2; in pwc_init_controls()
178 pdev->saturation_fmt = SATURATION_MODE_FORMATTER1; in pwc_init_controls()
179 r = pwc_get_s8_ctrl(pdev, GET_CHROM_CTL, pdev->saturation_fmt, in pwc_init_controls()
183 pdev->saturation = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
187 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, GAMMA_FORMATTER, &def); in pwc_init_controls()
190 pdev->gamma = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
194 r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL, WB_MODE_FORMATTER, &def); in pwc_init_controls()
200 pdev->auto_white_balance = v4l2_ctrl_new_custom(hdl, &cfg, NULL); in pwc_init_controls()
202 if (!pdev->auto_white_balance) in pwc_init_controls()
205 r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL, in pwc_init_controls()
209 pdev->red_balance = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
212 r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL, in pwc_init_controls()
216 pdev->blue_balance = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
219 v4l2_ctrl_auto_cluster(3, &pdev->auto_white_balance, awb_manual, true); in pwc_init_controls()
222 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, AGC_MODE_FORMATTER, &def); in pwc_init_controls()
226 pdev->autogain = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
228 if (!pdev->autogain) in pwc_init_controls()
231 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, PRESET_AGC_FORMATTER, &def); in pwc_init_controls()
234 pdev->gain = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
238 if (DEVICE_USE_CODEC2(pdev->type)) { in pwc_init_controls()
239 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, SHUTTER_MODE_FORMATTER, in pwc_init_controls()
247 pdev->exposure_auto = v4l2_ctrl_new_std_menu(hdl, in pwc_init_controls()
251 if (!pdev->exposure_auto) in pwc_init_controls()
255 r = pwc_get_u16_ctrl(pdev, GET_STATUS_CTL, in pwc_init_controls()
259 pdev->exposure = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
262 v4l2_ctrl_auto_cluster(2, &pdev->autogain, 0, true); in pwc_init_controls()
263 v4l2_ctrl_auto_cluster(2, &pdev->exposure_auto, in pwc_init_controls()
265 } else if (DEVICE_USE_CODEC3(pdev->type)) { in pwc_init_controls()
267 r = pwc_get_u16_ctrl(pdev, GET_STATUS_CTL, in pwc_init_controls()
271 pdev->exposure = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
274 pdev->autogain_expo_cluster[0] = pdev->autogain; in pwc_init_controls()
275 pdev->autogain_expo_cluster[1] = pdev->gain; in pwc_init_controls()
276 pdev->autogain_expo_cluster[2] = pdev->exposure; in pwc_init_controls()
277 v4l2_ctrl_auto_cluster(3, pdev->autogain_expo_cluster, in pwc_init_controls()
282 r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL, COLOUR_MODE_FORMATTER, in pwc_init_controls()
287 pdev->colorfx = v4l2_ctrl_new_std_menu(hdl, &pwc_ctrl_ops, in pwc_init_controls()
291 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, AUTO_CONTOUR_FORMATTER, &def); in pwc_init_controls()
296 pdev->autocontour = v4l2_ctrl_new_custom(hdl, &cfg, NULL); in pwc_init_controls()
297 if (!pdev->autocontour) in pwc_init_controls()
300 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, PRESET_CONTOUR_FORMATTER, &def); in pwc_init_controls()
305 pdev->contour = v4l2_ctrl_new_custom(hdl, &cfg, NULL); in pwc_init_controls()
307 v4l2_ctrl_auto_cluster(2, &pdev->autocontour, 0, false); in pwc_init_controls()
310 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, in pwc_init_controls()
317 pdev->backlight = v4l2_ctrl_new_custom(hdl, &cfg, NULL); in pwc_init_controls()
320 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, in pwc_init_controls()
327 pdev->flicker = v4l2_ctrl_new_custom(hdl, &cfg, NULL); in pwc_init_controls()
330 r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, in pwc_init_controls()
336 pdev->noise_reduction = v4l2_ctrl_new_custom(hdl, &cfg, NULL); in pwc_init_controls()
339 pdev->save_user = v4l2_ctrl_new_custom(hdl, &pwc_save_user_cfg, NULL); in pwc_init_controls()
340 pdev->restore_user = v4l2_ctrl_new_custom(hdl, &pwc_restore_user_cfg, in pwc_init_controls()
342 if (pdev->restore_user) in pwc_init_controls()
343 pdev->restore_user->flags |= V4L2_CTRL_FLAG_UPDATE; in pwc_init_controls()
344 pdev->restore_factory = v4l2_ctrl_new_custom(hdl, in pwc_init_controls()
347 if (pdev->restore_factory) in pwc_init_controls()
348 pdev->restore_factory->flags |= V4L2_CTRL_FLAG_UPDATE; in pwc_init_controls()
351 r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL, in pwc_init_controls()
357 pdev->awb_speed = v4l2_ctrl_new_custom(hdl, &cfg, NULL); in pwc_init_controls()
359 r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL, in pwc_init_controls()
365 pdev->awb_delay = v4l2_ctrl_new_custom(hdl, &cfg, NULL); in pwc_init_controls()
367 if (!(pdev->features & FEATURE_MOTOR_PANTILT)) in pwc_init_controls()
371 pdev->motor_pan = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
373 if (!pdev->motor_pan) in pwc_init_controls()
375 pdev->motor_tilt = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
377 pdev->motor_pan_reset = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
379 pdev->motor_tilt_reset = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops, in pwc_init_controls()
381 v4l2_ctrl_cluster(4, &pdev->motor_pan); in pwc_init_controls()
409 static int pwc_vidioc_try_fmt(struct pwc_device *pdev, struct v4l2_format *f) in pwc_vidioc_try_fmt() argument
422 if (DEVICE_USE_CODEC23(pdev->type)) { in pwc_vidioc_try_fmt()
428 if (DEVICE_USE_CODEC1(pdev->type)) { in pwc_vidioc_try_fmt()
438 size = pwc_get_size(pdev, f->fmt.pix.width, f->fmt.pix.height); in pwc_vidioc_try_fmt()
451 struct pwc_device *pdev = video_drvdata(file); in pwc_s_fmt_vid_cap() local
454 ret = pwc_vidioc_try_fmt(pdev, f); in pwc_s_fmt_vid_cap()
458 if (vb2_is_busy(&pdev->vb_queue)) in pwc_s_fmt_vid_cap()
464 f->fmt.pix.width, f->fmt.pix.height, pdev->vframes, in pwc_s_fmt_vid_cap()
470 ret = pwc_set_video_mode(pdev, f->fmt.pix.width, f->fmt.pix.height, in pwc_s_fmt_vid_cap()
475 pwc_vidioc_fill_fmt(f, pdev->width, pdev->height, pdev->pixfmt); in pwc_s_fmt_vid_cap()
481 struct pwc_device *pdev = video_drvdata(file); in pwc_querycap() local
484 strscpy(cap->card, pdev->vdev.name, sizeof(cap->card)); in pwc_querycap()
485 usb_make_path(pdev->udev, cap->bus_info, sizeof(cap->bus_info)); in pwc_querycap()
512 struct pwc_device *pdev = in pwc_g_volatile_ctrl() local
518 if (pdev->color_bal_valid && in pwc_g_volatile_ctrl()
519 (pdev->auto_white_balance->val != awb_auto || in pwc_g_volatile_ctrl()
521 pdev->last_color_bal_update + HZ / 4))) { in pwc_g_volatile_ctrl()
522 pdev->red_balance->val = pdev->last_red_balance; in pwc_g_volatile_ctrl()
523 pdev->blue_balance->val = pdev->last_blue_balance; in pwc_g_volatile_ctrl()
526 ret = pwc_get_u8_ctrl(pdev, GET_STATUS_CTL, in pwc_g_volatile_ctrl()
528 &pdev->red_balance->val); in pwc_g_volatile_ctrl()
531 ret = pwc_get_u8_ctrl(pdev, GET_STATUS_CTL, in pwc_g_volatile_ctrl()
533 &pdev->blue_balance->val); in pwc_g_volatile_ctrl()
536 pdev->last_red_balance = pdev->red_balance->val; in pwc_g_volatile_ctrl()
537 pdev->last_blue_balance = pdev->blue_balance->val; in pwc_g_volatile_ctrl()
538 pdev->last_color_bal_update = jiffies; in pwc_g_volatile_ctrl()
539 pdev->color_bal_valid = true; in pwc_g_volatile_ctrl()
542 if (pdev->gain_valid && time_before(jiffies, in pwc_g_volatile_ctrl()
543 pdev->last_gain_update + HZ / 4)) { in pwc_g_volatile_ctrl()
544 pdev->gain->val = pdev->last_gain; in pwc_g_volatile_ctrl()
547 ret = pwc_get_u8_ctrl(pdev, GET_STATUS_CTL, in pwc_g_volatile_ctrl()
548 READ_AGC_FORMATTER, &pdev->gain->val); in pwc_g_volatile_ctrl()
551 pdev->last_gain = pdev->gain->val; in pwc_g_volatile_ctrl()
552 pdev->last_gain_update = jiffies; in pwc_g_volatile_ctrl()
553 pdev->gain_valid = true; in pwc_g_volatile_ctrl()
554 if (!DEVICE_USE_CODEC3(pdev->type)) in pwc_g_volatile_ctrl()
559 if (pdev->exposure_valid && time_before(jiffies, in pwc_g_volatile_ctrl()
560 pdev->last_exposure_update + HZ / 4)) { in pwc_g_volatile_ctrl()
561 pdev->exposure->val = pdev->last_exposure; in pwc_g_volatile_ctrl()
564 ret = pwc_get_u16_ctrl(pdev, GET_STATUS_CTL, in pwc_g_volatile_ctrl()
566 &pdev->exposure->val); in pwc_g_volatile_ctrl()
569 pdev->last_exposure = pdev->exposure->val; in pwc_g_volatile_ctrl()
570 pdev->last_exposure_update = jiffies; in pwc_g_volatile_ctrl()
571 pdev->exposure_valid = true; in pwc_g_volatile_ctrl()
583 static int pwc_set_awb(struct pwc_device *pdev) in pwc_set_awb() argument
587 if (pdev->auto_white_balance->is_new) { in pwc_set_awb()
588 ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL, in pwc_set_awb()
590 pdev->auto_white_balance->val); in pwc_set_awb()
594 if (pdev->auto_white_balance->val != awb_manual) in pwc_set_awb()
595 pdev->color_bal_valid = false; /* Force cache update */ in pwc_set_awb()
601 if (pdev->auto_white_balance->val == awb_indoor || in pwc_set_awb()
602 pdev->auto_white_balance->val == awb_outdoor || in pwc_set_awb()
603 pdev->auto_white_balance->val == awb_fl) in pwc_set_awb()
604 pwc_g_volatile_ctrl(pdev->auto_white_balance); in pwc_set_awb()
606 if (pdev->auto_white_balance->val != awb_manual) in pwc_set_awb()
609 if (pdev->red_balance->is_new) { in pwc_set_awb()
610 ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL, in pwc_set_awb()
612 pdev->red_balance->val); in pwc_set_awb()
617 if (pdev->blue_balance->is_new) { in pwc_set_awb()
618 ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL, in pwc_set_awb()
620 pdev->blue_balance->val); in pwc_set_awb()
628 static int pwc_set_autogain(struct pwc_device *pdev) in pwc_set_autogain() argument
632 if (pdev->autogain->is_new) { in pwc_set_autogain()
633 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_set_autogain()
635 pdev->autogain->val ? 0 : 0xff); in pwc_set_autogain()
639 if (pdev->autogain->val) in pwc_set_autogain()
640 pdev->gain_valid = false; /* Force cache update */ in pwc_set_autogain()
643 if (pdev->autogain->val) in pwc_set_autogain()
646 if (pdev->gain->is_new) { in pwc_set_autogain()
647 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_set_autogain()
649 pdev->gain->val); in pwc_set_autogain()
657 static int pwc_set_exposure_auto(struct pwc_device *pdev) in pwc_set_exposure_auto() argument
660 int is_auto = pdev->exposure_auto->val == V4L2_EXPOSURE_AUTO; in pwc_set_exposure_auto()
662 if (pdev->exposure_auto->is_new) { in pwc_set_exposure_auto()
663 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_set_exposure_auto()
670 pdev->exposure_valid = false; /* Force cache update */ in pwc_set_exposure_auto()
676 if (pdev->exposure->is_new) { in pwc_set_exposure_auto()
677 ret = pwc_set_u16_ctrl(pdev, SET_LUM_CTL, in pwc_set_exposure_auto()
679 pdev->exposure->val); in pwc_set_exposure_auto()
687 static int pwc_set_autogain_expo(struct pwc_device *pdev) in pwc_set_autogain_expo() argument
691 if (pdev->autogain->is_new) { in pwc_set_autogain_expo()
692 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_set_autogain_expo()
694 pdev->autogain->val ? 0 : 0xff); in pwc_set_autogain_expo()
698 if (pdev->autogain->val) { in pwc_set_autogain_expo()
699 pdev->gain_valid = false; /* Force cache update */ in pwc_set_autogain_expo()
700 pdev->exposure_valid = false; /* Force cache update */ in pwc_set_autogain_expo()
704 if (pdev->autogain->val) in pwc_set_autogain_expo()
707 if (pdev->gain->is_new) { in pwc_set_autogain_expo()
708 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_set_autogain_expo()
710 pdev->gain->val); in pwc_set_autogain_expo()
715 if (pdev->exposure->is_new) { in pwc_set_autogain_expo()
716 ret = pwc_set_u16_ctrl(pdev, SET_LUM_CTL, in pwc_set_autogain_expo()
718 pdev->exposure->val); in pwc_set_autogain_expo()
725 static int pwc_set_motor(struct pwc_device *pdev) in pwc_set_motor() argument
729 pdev->ctrl_buf[0] = 0; in pwc_set_motor()
730 if (pdev->motor_pan_reset->is_new) in pwc_set_motor()
731 pdev->ctrl_buf[0] |= 0x01; in pwc_set_motor()
732 if (pdev->motor_tilt_reset->is_new) in pwc_set_motor()
733 pdev->ctrl_buf[0] |= 0x02; in pwc_set_motor()
734 if (pdev->motor_pan_reset->is_new || pdev->motor_tilt_reset->is_new) { in pwc_set_motor()
735 ret = send_control_msg(pdev, SET_MPT_CTL, in pwc_set_motor()
737 pdev->ctrl_buf, 1); in pwc_set_motor()
742 memset(pdev->ctrl_buf, 0, 4); in pwc_set_motor()
743 if (pdev->motor_pan->is_new) { in pwc_set_motor()
744 pdev->ctrl_buf[0] = pdev->motor_pan->val & 0xFF; in pwc_set_motor()
745 pdev->ctrl_buf[1] = (pdev->motor_pan->val >> 8); in pwc_set_motor()
747 if (pdev->motor_tilt->is_new) { in pwc_set_motor()
748 pdev->ctrl_buf[2] = pdev->motor_tilt->val & 0xFF; in pwc_set_motor()
749 pdev->ctrl_buf[3] = (pdev->motor_tilt->val >> 8); in pwc_set_motor()
751 if (pdev->motor_pan->is_new || pdev->motor_tilt->is_new) { in pwc_set_motor()
752 ret = send_control_msg(pdev, SET_MPT_CTL, in pwc_set_motor()
754 pdev->ctrl_buf, 4); in pwc_set_motor()
764 struct pwc_device *pdev = in pwc_s_ctrl() local
770 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_s_ctrl()
774 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_s_ctrl()
778 ret = pwc_set_s8_ctrl(pdev, SET_CHROM_CTL, in pwc_s_ctrl()
779 pdev->saturation_fmt, ctrl->val); in pwc_s_ctrl()
782 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_s_ctrl()
786 ret = pwc_set_awb(pdev); in pwc_s_ctrl()
789 if (DEVICE_USE_CODEC2(pdev->type)) in pwc_s_ctrl()
790 ret = pwc_set_autogain(pdev); in pwc_s_ctrl()
791 else if (DEVICE_USE_CODEC3(pdev->type)) in pwc_s_ctrl()
792 ret = pwc_set_autogain_expo(pdev); in pwc_s_ctrl()
797 if (DEVICE_USE_CODEC2(pdev->type)) in pwc_s_ctrl()
798 ret = pwc_set_exposure_auto(pdev); in pwc_s_ctrl()
803 ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL, in pwc_s_ctrl()
808 if (pdev->autocontour->is_new) { in pwc_s_ctrl()
809 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_s_ctrl()
811 pdev->autocontour->val ? 0 : 0xff); in pwc_s_ctrl()
813 if (ret == 0 && pdev->contour->is_new) { in pwc_s_ctrl()
814 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_s_ctrl()
816 pdev->contour->val); in pwc_s_ctrl()
820 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_s_ctrl()
825 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_s_ctrl()
830 ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL, in pwc_s_ctrl()
835 ret = pwc_button_ctrl(pdev, SAVE_USER_DEFAULTS_FORMATTER); in pwc_s_ctrl()
838 ret = pwc_button_ctrl(pdev, RESTORE_USER_DEFAULTS_FORMATTER); in pwc_s_ctrl()
841 ret = pwc_button_ctrl(pdev, in pwc_s_ctrl()
845 ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL, in pwc_s_ctrl()
850 ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL, in pwc_s_ctrl()
855 ret = pwc_set_motor(pdev); in pwc_s_ctrl()
869 struct pwc_device *pdev = video_drvdata(file); in pwc_enum_fmt_vid_cap() local
875 f->pixelformat = pdev->type <= 646 ? V4L2_PIX_FMT_PWC1 : V4L2_PIX_FMT_PWC2; in pwc_enum_fmt_vid_cap()
888 struct pwc_device *pdev = video_drvdata(file); in pwc_g_fmt_vid_cap() local
894 pdev->width, pdev->height); in pwc_g_fmt_vid_cap()
895 pwc_vidioc_fill_fmt(f, pdev->width, pdev->height, pdev->pixfmt); in pwc_g_fmt_vid_cap()
901 struct pwc_device *pdev = video_drvdata(file); in pwc_try_fmt_vid_cap() local
903 return pwc_vidioc_try_fmt(pdev, f); in pwc_try_fmt_vid_cap()
909 struct pwc_device *pdev = video_drvdata(file); in pwc_enum_framesizes() local
914 DEVICE_USE_CODEC1(pdev->type)) || in pwc_enum_framesizes()
916 DEVICE_USE_CODEC23(pdev->type))) { in pwc_enum_framesizes()
918 if (!(pdev->image_mask & (1UL << i))) in pwc_enum_framesizes()
934 struct pwc_device *pdev = video_drvdata(file); in pwc_enum_frameintervals() local
950 i = pwc_get_fps(pdev, fival->index, size); in pwc_enum_frameintervals()
964 struct pwc_device *pdev = video_drvdata(file); in pwc_g_parm() local
974 parm->parm.capture.timeperframe.denominator = pdev->vframes; in pwc_g_parm()
983 struct pwc_device *pdev = video_drvdata(file); in pwc_s_parm() local
1000 if (vb2_is_busy(&pdev->vb_queue)) in pwc_s_parm()
1003 ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt, in pwc_s_parm()