aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorThierry MERLE <thierry.merle@free.fr>2008-01-10 16:20:34 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:04:57 -0500
commit6200bbaa5bd8b6751931364dfa4aa1cdd5efa686 (patch)
treec0cd20d52802bcecf5cb005dc7289f03e9aa1204 /drivers/media
parent1f8d30083abc17897b897787c39d446eb9d99fe0 (diff)
V4L/DVB (7024): usbvision: YUV to RGB conversion fixes
All YUV to RGB conversions in usbvision were reverted (conversion to BGR but saying RGB to the application) Signed-off-by: Thierry MERLE <thierry.merle@free.fr> Acked-by: Dwaine Garden <DwaineGarden@rogers.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/usbvision/usbvision-core.c300
1 files changed, 166 insertions, 134 deletions
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c
index 1e52a0387aa5..56775ab8b75d 100644
--- a/drivers/media/video/usbvision/usbvision-core.c
+++ b/drivers/media/video/usbvision/usbvision-core.c
@@ -633,25 +633,29 @@ static enum ParseState usbvision_parse_lines_422(struct usb_usbvision *usbvision
633 633
634 YUV_TO_RGB_BY_THE_BOOK(yuyv[0], yuyv[1], yuyv[3], rv, gv, bv); 634 YUV_TO_RGB_BY_THE_BOOK(yuyv[0], yuyv[1], yuyv[3], rv, gv, bv);
635 switch (frame->v4l2_format.format) { 635 switch (frame->v4l2_format.format) {
636 case V4L2_PIX_FMT_RGB565: 636 case V4L2_PIX_FMT_RGB565:
637 *f++ = (0x1F & (bv >> 3)) | (0xE0 & (gv << 3)); 637 *f++ = (0x1F & rv) |
638 *f++ = (0x07 & (gv >> 5)) | (0xF8 & rv); 638 (0xE0 & (gv << 5));
639 break; 639 *f++ = (0x07 & (gv >> 3)) |
640 case V4L2_PIX_FMT_RGB24: 640 (0xF8 & bv);
641 *f++ = bv; 641 break;
642 *f++ = gv; 642 case V4L2_PIX_FMT_RGB24:
643 *f++ = rv; 643 *f++ = rv;
644 break; 644 *f++ = gv;
645 case V4L2_PIX_FMT_RGB32: 645 *f++ = bv;
646 *f++ = bv; 646 break;
647 *f++ = gv; 647 case V4L2_PIX_FMT_RGB32:
648 *f++ = rv; 648 *f++ = rv;
649 f++; 649 *f++ = gv;
650 break; 650 *f++ = bv;
651 case V4L2_PIX_FMT_RGB555: 651 f++;
652 *f++ = (0x1F & (bv >> 3)) | (0xE0 & (gv << 2)); 652 break;
653 *f++ = (0x03 & (gv >> 6)) | (0x7C & (rv >> 1)); 653 case V4L2_PIX_FMT_RGB555:
654 break; 654 *f++ = (0x1F & rv) |
655 (0xE0 & (gv << 5));
656 *f++ = (0x03 & (gv >> 3)) |
657 (0x7C & (bv << 2));
658 break;
655 } 659 }
656 } 660 }
657 clipmask_index += clipmask_add; 661 clipmask_index += clipmask_add;
@@ -665,25 +669,29 @@ static enum ParseState usbvision_parse_lines_422(struct usb_usbvision *usbvision
665 669
666 YUV_TO_RGB_BY_THE_BOOK(yuyv[2], yuyv[1], yuyv[3], rv, gv, bv); 670 YUV_TO_RGB_BY_THE_BOOK(yuyv[2], yuyv[1], yuyv[3], rv, gv, bv);
667 switch (frame->v4l2_format.format) { 671 switch (frame->v4l2_format.format) {
668 case V4L2_PIX_FMT_RGB565: 672 case V4L2_PIX_FMT_RGB565:
669 *f++ = (0x1F & (bv >> 3)) | (0xE0 & (gv << 3)); 673 *f++ = (0x1F & rv) |
670 *f++ = (0x07 & (gv >> 5)) | (0xF8 & rv); 674 (0xE0 & (gv << 5));
671 break; 675 *f++ = (0x07 & (gv >> 3)) |
672 case V4L2_PIX_FMT_RGB24: 676 (0xF8 & bv);
673 *f++ = bv; 677 break;
674 *f++ = gv; 678 case V4L2_PIX_FMT_RGB24:
675 *f++ = rv; 679 *f++ = rv;
676 break; 680 *f++ = gv;
677 case V4L2_PIX_FMT_RGB32: 681 *f++ = bv;
678 *f++ = bv; 682 break;
679 *f++ = gv; 683 case V4L2_PIX_FMT_RGB32:
680 *f++ = rv; 684 *f++ = rv;
681 f++; 685 *f++ = gv;
682 break; 686 *f++ = bv;
683 case V4L2_PIX_FMT_RGB555: 687 f++;
684 *f++ = (0x1F & (bv >> 3)) | (0xE0 & (gv << 2)); 688 break;
685 *f++ = (0x03 & (gv >> 6)) | (0x7C & (rv >> 1)); 689 case V4L2_PIX_FMT_RGB555:
686 break; 690 *f++ = (0x1F & rv) |
691 (0xE0 & (gv << 5));
692 *f++ = (0x03 & (gv >> 3)) |
693 (0x7C & (bv << 2));
694 break;
687 } 695 }
688 } 696 }
689 clipmask_index += clipmask_add; 697 clipmask_index += clipmask_add;
@@ -951,22 +959,26 @@ static enum ParseState usbvision_parse_compress(struct usb_usbvision *usbvision,
951 *f++ = Y[Idx]; 959 *f++ = Y[Idx];
952 break; 960 break;
953 case V4L2_PIX_FMT_RGB555: 961 case V4L2_PIX_FMT_RGB555:
954 *f++ = (0x1F & (bv >> 3)) | (0xE0 & (gv << 2)); 962 *f++ = (0x1F & rv) |
955 *f++ = (0x03 & (gv >> 6)) | (0x7C & (rv >> 1)); 963 (0xE0 & (gv << 5));
964 *f++ = (0x03 & (gv >> 3)) |
965 (0x7C & (bv << 2));
956 break; 966 break;
957 case V4L2_PIX_FMT_RGB565: 967 case V4L2_PIX_FMT_RGB565:
958 *f++ = (0x1F & (bv >> 3)) | (0xE0 & (gv << 3)); 968 *f++ = (0x1F & rv) |
959 *f++ = (0x07 & (gv >> 5)) | (0xF8 & rv); 969 (0xE0 & (gv << 5));
970 *f++ = (0x07 & (gv >> 3)) |
971 (0xF8 & bv);
960 break; 972 break;
961 case V4L2_PIX_FMT_RGB24: 973 case V4L2_PIX_FMT_RGB24:
962 *f++ = bv;
963 *f++ = gv;
964 *f++ = rv; 974 *f++ = rv;
975 *f++ = gv;
976 *f++ = bv;
965 break; 977 break;
966 case V4L2_PIX_FMT_RGB32: 978 case V4L2_PIX_FMT_RGB32:
967 *f++ = bv;
968 *f++ = gv;
969 *f++ = rv; 979 *f++ = rv;
980 *f++ = gv;
981 *f++ = bv;
970 f++; 982 f++;
971 break; 983 break;
972 } 984 }
@@ -1080,28 +1092,33 @@ static enum ParseState usbvision_parse_lines_420(struct usb_usbvision *usbvision
1080 r_ = (y_ + ur) >> 16; 1092 r_ = (y_ + ur) >> 16;
1081 1093
1082 switch (frame->v4l2_format.format) { 1094 switch (frame->v4l2_format.format) {
1083 case V4L2_PIX_FMT_RGB565: 1095 case V4L2_PIX_FMT_RGB565:
1084 g = LIMIT_RGB(g_); 1096 g = LIMIT_RGB(g_);
1085 *f_even++ = (0x1F & (LIMIT_RGB(b_) >> 3)) | (0xE0 & (g << 3)); 1097 *f_even++ =
1086 *f_even++ = (0x07 & ( g >> 5)) | (0xF8 & LIMIT_RGB(r_)); 1098 (0x1F & LIMIT_RGB(r_)) |
1087 break; 1099 (0xE0 & (g << 5));
1088 case V4L2_PIX_FMT_RGB24: 1100 *f_even++ =
1089 *f_even++ = LIMIT_RGB(b_); 1101 (0x07 & (g >> 3)) |
1090 *f_even++ = LIMIT_RGB(g_); 1102 (0xF8 & LIMIT_RGB(b_));
1091 *f_even++ = LIMIT_RGB(r_); 1103 break;
1092 break; 1104 case V4L2_PIX_FMT_RGB24:
1093 case V4L2_PIX_FMT_RGB32: 1105 *f_even++ = LIMIT_RGB(r_);
1094 *f_even++ = LIMIT_RGB(b_); 1106 *f_even++ = LIMIT_RGB(g_);
1095 *f_even++ = LIMIT_RGB(g_); 1107 *f_even++ = LIMIT_RGB(b_);
1096 *f_even++ = LIMIT_RGB(r_); 1108 break;
1097 f_even++; 1109 case V4L2_PIX_FMT_RGB32:
1098 break; 1110 *f_even++ = LIMIT_RGB(r_);
1099 case V4L2_PIX_FMT_RGB555: 1111 *f_even++ = LIMIT_RGB(g_);
1100 g = LIMIT_RGB(g_); 1112 *f_even++ = LIMIT_RGB(b_);
1101 *f_even++ = (0x1F & (LIMIT_RGB(b_) >> 3)) | (0xE0 & (g << 2)); 1113 f_even++;
1102 *f_even++ = (0x03 & ( g >> 6)) | 1114 break;
1103 (0x7C & (LIMIT_RGB(r_) >> 1)); 1115 case V4L2_PIX_FMT_RGB555:
1104 break; 1116 g = LIMIT_RGB(g_);
1117 *f_even++ = (0x1F & LIMIT_RGB(r_)) |
1118 (0xE0 & (g << 5));
1119 *f_even++ = (0x03 & (g >> 3)) |
1120 (0x7C & (LIMIT_RGB(b_) << 2));
1121 break;
1105 } 1122 }
1106 } 1123 }
1107 clipmask_even_index += clipmask_add; 1124 clipmask_even_index += clipmask_add;
@@ -1119,28 +1136,33 @@ static enum ParseState usbvision_parse_lines_420(struct usb_usbvision *usbvision
1119 r_ = (y_ + ur) >> 16; 1136 r_ = (y_ + ur) >> 16;
1120 1137
1121 switch (frame->v4l2_format.format) { 1138 switch (frame->v4l2_format.format) {
1122 case V4L2_PIX_FMT_RGB565: 1139 case V4L2_PIX_FMT_RGB565:
1123 g = LIMIT_RGB(g_); 1140 g = LIMIT_RGB(g_);
1124 *f_even++ = (0x1F & (LIMIT_RGB(b_) >> 3)) | (0xE0 & (g << 3)); 1141 *f_even++ =
1125 *f_even++ = (0x07 & ( g >> 5)) | (0xF8 & LIMIT_RGB(r_)); 1142 (0x1F & LIMIT_RGB(r_)) |
1126 break; 1143 (0xE0 & (g << 5));
1127 case V4L2_PIX_FMT_RGB24: 1144 *f_even++ =
1128 *f_even++ = LIMIT_RGB(b_); 1145 (0x07 & (g >> 3)) |
1129 *f_even++ = LIMIT_RGB(g_); 1146 (0xF8 & LIMIT_RGB(b_));
1130 *f_even++ = LIMIT_RGB(r_); 1147 break;
1131 break; 1148 case V4L2_PIX_FMT_RGB24:
1132 case V4L2_PIX_FMT_RGB32: 1149 *f_even++ = LIMIT_RGB(r_);
1133 *f_even++ = LIMIT_RGB(b_); 1150 *f_even++ = LIMIT_RGB(g_);
1134 *f_even++ = LIMIT_RGB(g_); 1151 *f_even++ = LIMIT_RGB(b_);
1135 *f_even++ = LIMIT_RGB(r_); 1152 break;
1136 f_even++; 1153 case V4L2_PIX_FMT_RGB32:
1137 break; 1154 *f_even++ = LIMIT_RGB(r_);
1138 case V4L2_PIX_FMT_RGB555: 1155 *f_even++ = LIMIT_RGB(g_);
1139 g = LIMIT_RGB(g_); 1156 *f_even++ = LIMIT_RGB(b_);
1140 *f_even++ = (0x1F & (LIMIT_RGB(b_) >> 3)) | (0xE0 & (g << 2)); 1157 f_even++;
1141 *f_even++ = (0x03 & ( g >> 6)) | 1158 break;
1142 (0x7C & (LIMIT_RGB(r_) >> 1)); 1159 case V4L2_PIX_FMT_RGB555:
1143 break; 1160 g = LIMIT_RGB(g_);
1161 *f_even++ = (0x1F & LIMIT_RGB(r_)) |
1162 (0xE0 & (g << 5));
1163 *f_even++ = (0x03 & (g >> 3)) |
1164 (0x7C & (LIMIT_RGB(b_) << 2));
1165 break;
1144 } 1166 }
1145 } 1167 }
1146 clipmask_even_index += clipmask_add; 1168 clipmask_even_index += clipmask_add;
@@ -1160,28 +1182,33 @@ static enum ParseState usbvision_parse_lines_420(struct usb_usbvision *usbvision
1160 r_ = (y_ + ur) >> 16; 1182 r_ = (y_ + ur) >> 16;
1161 1183
1162 switch (frame->v4l2_format.format) { 1184 switch (frame->v4l2_format.format) {
1163 case V4L2_PIX_FMT_RGB565: 1185 case V4L2_PIX_FMT_RGB565:
1164 g = LIMIT_RGB(g_); 1186 g = LIMIT_RGB(g_);
1165 *f_odd++ = (0x1F & (LIMIT_RGB(b_) >> 3)) | (0xE0 & (g << 3)); 1187 *f_odd++ =
1166 *f_odd++ = (0x07 & ( g >> 5)) | (0xF8 & LIMIT_RGB(r_)); 1188 (0x1F & LIMIT_RGB(r_)) |
1167 break; 1189 (0xE0 & (g << 5));
1168 case V4L2_PIX_FMT_RGB24: 1190 *f_odd++ =
1169 *f_odd++ = LIMIT_RGB(b_); 1191 (0x07 & (g >> 3)) |
1170 *f_odd++ = LIMIT_RGB(g_); 1192 (0xF8 & LIMIT_RGB(b_));
1171 *f_odd++ = LIMIT_RGB(r_); 1193 break;
1172 break; 1194 case V4L2_PIX_FMT_RGB24:
1173 case V4L2_PIX_FMT_RGB32: 1195 *f_odd++ = LIMIT_RGB(r_);
1174 *f_odd++ = LIMIT_RGB(b_); 1196 *f_odd++ = LIMIT_RGB(g_);
1175 *f_odd++ = LIMIT_RGB(g_); 1197 *f_odd++ = LIMIT_RGB(b_);
1176 *f_odd++ = LIMIT_RGB(r_); 1198 break;
1177 f_odd++; 1199 case V4L2_PIX_FMT_RGB32:
1178 break; 1200 *f_odd++ = LIMIT_RGB(r_);
1179 case V4L2_PIX_FMT_RGB555: 1201 *f_odd++ = LIMIT_RGB(g_);
1180 g = LIMIT_RGB(g_); 1202 *f_odd++ = LIMIT_RGB(b_);
1181 *f_odd++ = (0x1F & (LIMIT_RGB(b_) >> 3)) | (0xE0 & (g << 2)); 1203 f_odd++;
1182 *f_odd++ = (0x03 & ( g >> 6)) | 1204 break;
1183 (0x7C & (LIMIT_RGB(r_) >> 1)); 1205 case V4L2_PIX_FMT_RGB555:
1184 break; 1206 g = LIMIT_RGB(g_);
1207 *f_odd++ = (0x1F & LIMIT_RGB(r_)) |
1208 (0xE0 & (g << 5));
1209 *f_odd++ = (0x03 & (g >> 3)) |
1210 (0x7C & (LIMIT_RGB(b_) << 2));
1211 break;
1185 } 1212 }
1186 } 1213 }
1187 clipmask_odd_index += clipmask_add; 1214 clipmask_odd_index += clipmask_add;
@@ -1199,28 +1226,33 @@ static enum ParseState usbvision_parse_lines_420(struct usb_usbvision *usbvision
1199 r_ = (y_ + ur) >> 16; 1226 r_ = (y_ + ur) >> 16;
1200 1227
1201 switch (frame->v4l2_format.format) { 1228 switch (frame->v4l2_format.format) {
1202 case V4L2_PIX_FMT_RGB565: 1229 case V4L2_PIX_FMT_RGB565:
1203 g = LIMIT_RGB(g_); 1230 g = LIMIT_RGB(g_);
1204 *f_odd++ = (0x1F & (LIMIT_RGB(b_) >> 3)) | (0xE0 & (g << 3)); 1231 *f_odd++ =
1205 *f_odd++ = (0x07 & ( g >> 5)) | (0xF8 & LIMIT_RGB(r_)); 1232 (0x1F & LIMIT_RGB(r_)) |
1206 break; 1233 (0xE0 & (g << 5));
1207 case V4L2_PIX_FMT_RGB24: 1234 *f_odd++ =
1208 *f_odd++ = LIMIT_RGB(b_); 1235 (0x07 & (g >> 3)) |
1209 *f_odd++ = LIMIT_RGB(g_); 1236 (0xF8 & LIMIT_RGB(b_));
1210 *f_odd++ = LIMIT_RGB(r_); 1237 break;
1211 break; 1238 case V4L2_PIX_FMT_RGB24:
1212 case V4L2_PIX_FMT_RGB32: 1239 *f_odd++ = LIMIT_RGB(r_);
1213 *f_odd++ = LIMIT_RGB(b_); 1240 *f_odd++ = LIMIT_RGB(g_);
1214 *f_odd++ = LIMIT_RGB(g_); 1241 *f_odd++ = LIMIT_RGB(b_);
1215 *f_odd++ = LIMIT_RGB(r_); 1242 break;
1216 f_odd++; 1243 case V4L2_PIX_FMT_RGB32:
1217 break; 1244 *f_odd++ = LIMIT_RGB(r_);
1218 case V4L2_PIX_FMT_RGB555: 1245 *f_odd++ = LIMIT_RGB(g_);
1219 g = LIMIT_RGB(g_); 1246 *f_odd++ = LIMIT_RGB(b_);
1220 *f_odd++ = (0x1F & (LIMIT_RGB(b_) >> 3)) | (0xE0 & (g << 2)); 1247 f_odd++;
1221 *f_odd++ = (0x03 & ( g >> 6)) | 1248 break;
1222 (0x7C & (LIMIT_RGB(r_) >> 1)); 1249 case V4L2_PIX_FMT_RGB555:
1223 break; 1250 g = LIMIT_RGB(g_);
1251 *f_odd++ = (0x1F & LIMIT_RGB(r_)) |
1252 (0xE0 & (g << 5));
1253 *f_odd++ = (0x03 & (g >> 3)) |
1254 (0x7C & (LIMIT_RGB(b_) << 2));
1255 break;
1224 } 1256 }
1225 } 1257 }
1226 clipmask_odd_index += clipmask_add; 1258 clipmask_odd_index += clipmask_add;