diff --git a/mythtv/libs/libmythtv/v4lchannel.cpp b/mythtv/libs/libmythtv/v4lchannel.cpp
index 10792e8..e8cc73e 100644
a
|
b
|
bool V4LChannel::InitPictureAttribute(const QString db_col_name) |
882 | 882 | return false; |
883 | 883 | } |
884 | 884 | |
| 885 | if (driver_name == "hdpvr") |
| 886 | { |
| 887 | /* Myth assumes that 50% is "neutral", but the hdpvr has |
| 888 | * netural at 25% for contrast and color. Override the |
| 889 | * max returned by the hdpvr driver, so 25% gets mapped to |
| 890 | * 50% for myth. |
| 891 | */ |
| 892 | if (v4l2_attrib == V4L2_CID_CONTRAST || |
| 893 | v4l2_attrib == V4L2_CID_SATURATION) |
| 894 | qctrl.maximum = 0x7f; |
| 895 | } |
| 896 | |
885 | 897 | float new_range = qctrl.maximum - qctrl.minimum; |
886 | 898 | float old_range = 65535 - 0; |
887 | 899 | float scl_range = new_range / old_range; |
… |
… |
int V4LChannel::GetPictureAttribute(PictureAttribute attr) const |
990 | 1002 | return val; |
991 | 1003 | } |
992 | 1004 | |
993 | | static int get_v4l2_attribute_value(int videofd, int v4l2_attrib) |
| 1005 | static int get_v4l2_attribute_value(int videofd, int v4l2_attrib, |
| 1006 | const QString & driver_name) |
994 | 1007 | { |
995 | 1008 | struct v4l2_control ctrl; |
996 | 1009 | struct v4l2_queryctrl qctrl; |
… |
… |
static int get_v4l2_attribute_value(int videofd, int v4l2_attrib) |
1005 | 1018 | return -1; |
1006 | 1019 | } |
1007 | 1020 | |
| 1021 | if (driver_name == "hdpvr") |
| 1022 | { |
| 1023 | /* Myth assumes that 50% is "neutral", but the hdpvr has |
| 1024 | * netural at 25% for contrast and color. Override the |
| 1025 | * max returned by the hdpvr driver, so 25% gets mapped to |
| 1026 | * 50% for myth. |
| 1027 | */ |
| 1028 | if (v4l2_attrib == V4L2_CID_CONTRAST || |
| 1029 | v4l2_attrib == V4L2_CID_SATURATION) |
| 1030 | qctrl.maximum = 0x7f; |
| 1031 | } |
| 1032 | |
1008 | 1033 | if (ioctl(videofd, VIDIOC_G_CTRL, &ctrl) < 0) |
1009 | 1034 | { |
1010 | 1035 | LOG(VB_GENERAL, LOG_ERR, |
… |
… |
static int get_v4l1_attribute_value(int videofd, int v4l2_attrib) |
1038 | 1063 | return -1; |
1039 | 1064 | } |
1040 | 1065 | |
1041 | | static int get_attribute_value(bool usingv4l2, int videofd, int v4l2_attrib) |
| 1066 | static int get_attribute_value(bool usingv4l2, int videofd, int v4l2_attrib, |
| 1067 | const QString & driver_name) |
1042 | 1068 | { |
1043 | 1069 | if (usingv4l2) |
1044 | | return get_v4l2_attribute_value(videofd, v4l2_attrib); |
| 1070 | return get_v4l2_attribute_value(videofd, v4l2_attrib, driver_name); |
1045 | 1071 | return get_v4l1_attribute_value(videofd, v4l2_attrib); |
1046 | 1072 | } |
1047 | 1073 | |
1048 | | static int set_v4l2_attribute_value(int videofd, int v4l2_attrib, int newvalue) |
| 1074 | static int set_v4l2_attribute_value(int videofd, int v4l2_attrib, |
| 1075 | int newvalue, const QString & driver_name) |
1049 | 1076 | { |
1050 | 1077 | struct v4l2_control ctrl; |
1051 | 1078 | struct v4l2_queryctrl qctrl; |
… |
… |
static int set_v4l2_attribute_value(int videofd, int v4l2_attrib, int newvalue) |
1060 | 1087 | return -1; |
1061 | 1088 | } |
1062 | 1089 | |
| 1090 | if (driver_name == "hdpvr") |
| 1091 | { |
| 1092 | /* Myth assumes that 50% is "neutral", but the hdpvr has |
| 1093 | * netural at 25% for contrast and color. Override the |
| 1094 | * max returned by the hdpvr driver, so 25% gets mapped to |
| 1095 | * 50% for myth. |
| 1096 | */ |
| 1097 | if (v4l2_attrib == V4L2_CID_CONTRAST || |
| 1098 | v4l2_attrib == V4L2_CID_SATURATION) |
| 1099 | qctrl.maximum = 0x7f; |
| 1100 | } |
| 1101 | |
1063 | 1102 | float mult = (qctrl.maximum - qctrl.minimum) / 65535.0; |
1064 | 1103 | ctrl.value = (int)(mult * newvalue + qctrl.minimum); |
1065 | 1104 | ctrl.value = min(ctrl.value, qctrl.maximum); |
… |
… |
static int set_v4l1_attribute_value(int videofd, int v4l2_attrib, int newvalue) |
1112 | 1151 | } |
1113 | 1152 | |
1114 | 1153 | static int set_attribute_value(bool usingv4l2, int videofd, |
1115 | | int v4l2_attrib, int newvalue) |
| 1154 | int v4l2_attrib, int newvalue, |
| 1155 | const QString & driver_name) |
1116 | 1156 | { |
1117 | 1157 | if (usingv4l2) |
1118 | | return set_v4l2_attribute_value(videofd, v4l2_attrib, newvalue); |
| 1158 | return set_v4l2_attribute_value(videofd, v4l2_attrib, |
| 1159 | newvalue, driver_name); |
1119 | 1160 | return set_v4l1_attribute_value(videofd, v4l2_attrib, newvalue); |
1120 | 1161 | } |
1121 | 1162 | |
… |
… |
int V4LChannel::ChangePictureAttribute( |
1135 | 1176 | |
1136 | 1177 | // get the old attribute value from the hardware, this is |
1137 | 1178 | // just a sanity check on whether this attribute exists |
1138 | | if (get_attribute_value(usingv4l2, videofd, v4l2_attrib) < 0) |
| 1179 | if (get_attribute_value(usingv4l2, videofd, v4l2_attrib, driver_name) < 0) |
1139 | 1180 | return -1; |
1140 | 1181 | |
1141 | 1182 | int old_value = GetPictureAttribute(attr); |
… |
… |
int V4LChannel::ChangePictureAttribute( |
1154 | 1195 | #endif |
1155 | 1196 | |
1156 | 1197 | // actually set the new attribute value on the hardware |
1157 | | if (set_attribute_value(usingv4l2, videofd, v4l2_attrib, new_value) < 0) |
| 1198 | if (set_attribute_value(usingv4l2, videofd, v4l2_attrib, |
| 1199 | new_value, driver_name) < 0) |
1158 | 1200 | return -1; |
1159 | 1201 | |
1160 | 1202 | // tell the DB about the new attribute value |