aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/platform/coda/coda-common.c75
1 files changed, 7 insertions, 68 deletions
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 8b91bda784a7..b265edd8d277 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -61,11 +61,6 @@ int coda_debug;
61module_param(coda_debug, int, 0644); 61module_param(coda_debug, int, 0644);
62MODULE_PARM_DESC(coda_debug, "Debug level (0-2)"); 62MODULE_PARM_DESC(coda_debug, "Debug level (0-2)");
63 63
64struct coda_fmt {
65 char *name;
66 u32 fourcc;
67};
68
69void coda_write(struct coda_dev *dev, u32 data, u32 reg) 64void coda_write(struct coda_dev *dev, u32 data, u32 reg)
70{ 65{
71 v4l2_dbg(2, coda_debug, &dev->v4l2_dev, 66 v4l2_dbg(2, coda_debug, &dev->v4l2_dev,
@@ -111,40 +106,6 @@ void coda_write_base(struct coda_ctx *ctx, struct coda_q_data *q_data,
111 coda_write(ctx->dev, base_cr, reg_y + 8); 106 coda_write(ctx->dev, base_cr, reg_y + 8);
112} 107}
113 108
114/*
115 * Array of all formats supported by any version of Coda:
116 */
117static const struct coda_fmt coda_formats[] = {
118 {
119 .name = "YUV 4:2:0 Planar, YCbCr",
120 .fourcc = V4L2_PIX_FMT_YUV420,
121 },
122 {
123 .name = "YUV 4:2:0 Planar, YCrCb",
124 .fourcc = V4L2_PIX_FMT_YVU420,
125 },
126 {
127 .name = "YUV 4:2:0 Partial interleaved Y/CbCr",
128 .fourcc = V4L2_PIX_FMT_NV12,
129 },
130 {
131 .name = "YUV 4:2:2 Planar, YCbCr",
132 .fourcc = V4L2_PIX_FMT_YUV422P,
133 },
134 {
135 .name = "H264 Encoded Stream",
136 .fourcc = V4L2_PIX_FMT_H264,
137 },
138 {
139 .name = "MPEG4 Encoded Stream",
140 .fourcc = V4L2_PIX_FMT_MPEG4,
141 },
142 {
143 .name = "JPEG Encoded Images",
144 .fourcc = V4L2_PIX_FMT_JPEG,
145 },
146};
147
148#define CODA_CODEC(mode, src_fourcc, dst_fourcc, max_w, max_h) \ 109#define CODA_CODEC(mode, src_fourcc, dst_fourcc, max_w, max_h) \
149 { mode, src_fourcc, dst_fourcc, max_w, max_h } 110 { mode, src_fourcc, dst_fourcc, max_w, max_h }
150 111
@@ -261,40 +222,23 @@ static const struct coda_video_device *coda9_video_devices[] = {
261 &coda_bit_decoder, 222 &coda_bit_decoder,
262}; 223};
263 224
264static bool coda_format_is_yuv(u32 fourcc) 225/*
226 * Normalize all supported YUV 4:2:0 formats to the value used in the codec
227 * tables.
228 */
229static u32 coda_format_normalize_yuv(u32 fourcc)
265{ 230{
266 switch (fourcc) { 231 switch (fourcc) {
267 case V4L2_PIX_FMT_YUV420: 232 case V4L2_PIX_FMT_YUV420:
268 case V4L2_PIX_FMT_YVU420: 233 case V4L2_PIX_FMT_YVU420:
269 case V4L2_PIX_FMT_NV12: 234 case V4L2_PIX_FMT_NV12:
270 case V4L2_PIX_FMT_YUV422P: 235 case V4L2_PIX_FMT_YUV422P:
271 return true; 236 return V4L2_PIX_FMT_YUV420;
272 default: 237 default:
273 return false; 238 return fourcc;
274 } 239 }
275} 240}
276 241
277static const char *coda_format_name(u32 fourcc)
278{
279 int i;
280
281 for (i = 0; i < ARRAY_SIZE(coda_formats); i++) {
282 if (coda_formats[i].fourcc == fourcc)
283 return coda_formats[i].name;
284 }
285
286 return NULL;
287}
288
289/*
290 * Normalize all supported YUV 4:2:0 formats to the value used in the codec
291 * tables.
292 */
293static u32 coda_format_normalize_yuv(u32 fourcc)
294{
295 return coda_format_is_yuv(fourcc) ? V4L2_PIX_FMT_YUV420 : fourcc;
296}
297
298static const struct coda_codec *coda_find_codec(struct coda_dev *dev, 242static const struct coda_codec *coda_find_codec(struct coda_dev *dev,
299 int src_fourcc, int dst_fourcc) 243 int src_fourcc, int dst_fourcc)
300{ 244{
@@ -396,7 +340,6 @@ static int coda_enum_fmt(struct file *file, void *priv,
396 struct video_device *vdev = video_devdata(file); 340 struct video_device *vdev = video_devdata(file);
397 const struct coda_video_device *cvd = to_coda_video_device(vdev); 341 const struct coda_video_device *cvd = to_coda_video_device(vdev);
398 const u32 *formats; 342 const u32 *formats;
399 const char *name;
400 343
401 if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) 344 if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
402 formats = cvd->src_formats; 345 formats = cvd->src_formats;
@@ -408,11 +351,7 @@ static int coda_enum_fmt(struct file *file, void *priv,
408 if (f->index >= CODA_MAX_FORMATS || formats[f->index] == 0) 351 if (f->index >= CODA_MAX_FORMATS || formats[f->index] == 0)
409 return -EINVAL; 352 return -EINVAL;
410 353
411 name = coda_format_name(formats[f->index]);
412 strlcpy(f->description, name, sizeof(f->description));
413 f->pixelformat = formats[f->index]; 354 f->pixelformat = formats[f->index];
414 if (!coda_format_is_yuv(formats[f->index]))
415 f->flags |= V4L2_FMT_FLAG_COMPRESSED;
416 355
417 return 0; 356 return 0;
418} 357}