Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] hdpvr: update picture controls to support firmware versions > 0.15

Correctly sets the max/min/default values for the hdpvr picture
controls. The reason the current values didn't cause a problem until now
is because any firmware <= 0.15 didn't support them. The latest firmware
releases properly support picture controls and the values in the patch
are derived from the windows driver using SniffUSB2.0.

Thanks to Devin Heitmueller for helping me.

Signed-off-by: Taylor Ralph <tralph@mythtv.org>
Thanks-to: Devin Heitmueller <dheitmueller@kernellabs.com>
Acked-by: Jarod Wilson <jarod@redhat.com>
Reviewed-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Taylor Ralph and committed by
Mauro Carvalho Chehab
8423c0cf 2e2ba5d1

+48 -16
+16 -4
drivers/media/video/hdpvr/hdpvr-core.c
··· 154 154 } 155 155 #endif 156 156 157 - v4l2_info(&dev->v4l2_dev, "firmware version 0x%x dated %s\n", 158 - dev->usbc_buf[1], &dev->usbc_buf[2]); 157 + dev->fw_ver = dev->usbc_buf[1]; 159 158 160 - switch (dev->usbc_buf[1]) { 159 + v4l2_info(&dev->v4l2_dev, "firmware version 0x%x dated %s\n", 160 + dev->fw_ver, &dev->usbc_buf[2]); 161 + 162 + if (dev->fw_ver > 0x15) { 163 + dev->options.brightness = 0x80; 164 + dev->options.contrast = 0x40; 165 + dev->options.hue = 0xf; 166 + dev->options.saturation = 0x40; 167 + dev->options.sharpness = 0x80; 168 + } 169 + 170 + switch (dev->fw_ver) { 161 171 case HDPVR_FIRMWARE_VERSION: 162 172 dev->flags &= ~HDPVR_FLAG_AC3_CAP; 163 173 break; ··· 179 169 default: 180 170 v4l2_info(&dev->v4l2_dev, "untested firmware, the driver might" 181 171 " not work.\n"); 182 - if (dev->usbc_buf[1] >= HDPVR_FIRMWARE_VERSION_AC3) 172 + if (dev->fw_ver >= HDPVR_FIRMWARE_VERSION_AC3) 183 173 dev->flags |= HDPVR_FLAG_AC3_CAP; 184 174 else 185 175 dev->flags &= ~HDPVR_FLAG_AC3_CAP; ··· 280 270 .bitrate_mode = HDPVR_CONSTANT, 281 271 .gop_mode = HDPVR_SIMPLE_IDR_GOP, 282 272 .audio_codec = V4L2_MPEG_AUDIO_ENCODING_AAC, 273 + /* original picture controls for firmware version <= 0x15 */ 274 + /* updated in device_authorization() for newer firmware */ 283 275 .brightness = 0x86, 284 276 .contrast = 0x80, 285 277 .hue = 0x80,
+31 -12
drivers/media/video/hdpvr/hdpvr-video.c
··· 722 722 }; 723 723 724 724 static int fill_queryctrl(struct hdpvr_options *opt, struct v4l2_queryctrl *qc, 725 - int ac3) 725 + int ac3, int fw_ver) 726 726 { 727 727 int err; 728 728 729 + if (fw_ver > 0x15) { 730 + switch (qc->id) { 731 + case V4L2_CID_BRIGHTNESS: 732 + return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80); 733 + case V4L2_CID_CONTRAST: 734 + return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x40); 735 + case V4L2_CID_SATURATION: 736 + return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x40); 737 + case V4L2_CID_HUE: 738 + return v4l2_ctrl_query_fill(qc, 0x0, 0x1e, 1, 0xf); 739 + case V4L2_CID_SHARPNESS: 740 + return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80); 741 + } 742 + } else { 743 + switch (qc->id) { 744 + case V4L2_CID_BRIGHTNESS: 745 + return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x86); 746 + case V4L2_CID_CONTRAST: 747 + return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80); 748 + case V4L2_CID_SATURATION: 749 + return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80); 750 + case V4L2_CID_HUE: 751 + return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80); 752 + case V4L2_CID_SHARPNESS: 753 + return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80); 754 + } 755 + } 756 + 729 757 switch (qc->id) { 730 - case V4L2_CID_BRIGHTNESS: 731 - return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x86); 732 - case V4L2_CID_CONTRAST: 733 - return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80); 734 - case V4L2_CID_SATURATION: 735 - return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80); 736 - case V4L2_CID_HUE: 737 - return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80); 738 - case V4L2_CID_SHARPNESS: 739 - return v4l2_ctrl_query_fill(qc, 0x0, 0xff, 1, 0x80); 740 758 case V4L2_CID_MPEG_AUDIO_ENCODING: 741 759 return v4l2_ctrl_query_fill( 742 760 qc, V4L2_MPEG_AUDIO_ENCODING_AAC, ··· 812 794 813 795 if (qc->id == supported_v4l2_ctrls[i]) 814 796 return fill_queryctrl(&dev->options, qc, 815 - dev->flags & HDPVR_FLAG_AC3_CAP); 797 + dev->flags & HDPVR_FLAG_AC3_CAP, 798 + dev->fw_ver); 816 799 817 800 if (qc->id < supported_v4l2_ctrls[i]) 818 801 break;
+1
drivers/media/video/hdpvr/hdpvr.h
··· 113 113 /* usb control transfer buffer and lock */ 114 114 struct mutex usbc_mutex; 115 115 u8 *usbc_buf; 116 + u8 fw_ver; 116 117 }; 117 118 118 119 static inline struct hdpvr_device *to_hdpvr_dev(struct v4l2_device *v4l2_dev)