diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2011-11-24 09:15:23 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-10 20:21:52 -0500 |
commit | bb677f3ac434cb1708938f1e76a41d9098affd05 (patch) | |
tree | 334408194135fed6b8ab7599f2dcbd46e8fb4a2f /drivers/media/video/s5p-jpeg/jpeg-core.h | |
parent | aa73ab96bebb6fb9e0ee4429f78bfa3ef8c5b6b6 (diff) |
[media] Exynos4 JPEG codec v4l2 driver
Add driver for the JPEG codec IP block available in Samsung Exynos SoC series.
The driver is implemented as a V4L2 mem-to-mem device. It exposes two video
nodes to user space, one for the encoding part, and one for the decoding part.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Sakari Ailus <sakari.ailus@iki.fi>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Reviewed-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/s5p-jpeg/jpeg-core.h')
-rw-r--r-- | drivers/media/video/s5p-jpeg/jpeg-core.h | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/drivers/media/video/s5p-jpeg/jpeg-core.h b/drivers/media/video/s5p-jpeg/jpeg-core.h new file mode 100644 index 00000000000..facad6114f5 --- /dev/null +++ b/drivers/media/video/s5p-jpeg/jpeg-core.h | |||
@@ -0,0 +1,143 @@ | |||
1 | /* linux/drivers/media/video/s5p-jpeg/jpeg-core.h | ||
2 | * | ||
3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | ||
5 | * | ||
6 | * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #ifndef JPEG_CORE_H_ | ||
14 | #define JPEG_CORE_H_ | ||
15 | |||
16 | #include <media/v4l2-device.h> | ||
17 | |||
18 | #define S5P_JPEG_M2M_NAME "s5p-jpeg" | ||
19 | |||
20 | /* JPEG compression quality setting */ | ||
21 | #define S5P_JPEG_COMPR_QUAL_BEST 0 | ||
22 | #define S5P_JPEG_COMPR_QUAL_WORST 3 | ||
23 | |||
24 | /* JPEG RGB to YCbCr conversion matrix coefficients */ | ||
25 | #define S5P_JPEG_COEF11 0x4d | ||
26 | #define S5P_JPEG_COEF12 0x97 | ||
27 | #define S5P_JPEG_COEF13 0x1e | ||
28 | #define S5P_JPEG_COEF21 0x2c | ||
29 | #define S5P_JPEG_COEF22 0x57 | ||
30 | #define S5P_JPEG_COEF23 0x83 | ||
31 | #define S5P_JPEG_COEF31 0x83 | ||
32 | #define S5P_JPEG_COEF32 0x6e | ||
33 | #define S5P_JPEG_COEF33 0x13 | ||
34 | |||
35 | /* a selection of JPEG markers */ | ||
36 | #define TEM 0x01 | ||
37 | #define SOF0 0xc0 | ||
38 | #define RST 0xd0 | ||
39 | #define SOI 0xd8 | ||
40 | #define EOI 0xd9 | ||
41 | #define DHP 0xde | ||
42 | |||
43 | /* Flags that indicate a format can be used for capture/output */ | ||
44 | #define MEM2MEM_CAPTURE (1 << 0) | ||
45 | #define MEM2MEM_OUTPUT (1 << 1) | ||
46 | |||
47 | /** | ||
48 | * struct s5p_jpeg - JPEG IP abstraction | ||
49 | * @lock: the mutex protecting this structure | ||
50 | * @v4l2_dev: v4l2 device for mem2mem mode | ||
51 | * @vfd_encoder: video device node for encoder mem2mem mode | ||
52 | * @vfd_decoder: video device node for decoder mem2mem mode | ||
53 | * @m2m_dev: v4l2 mem2mem device data | ||
54 | * @ioarea: JPEG IP memory region | ||
55 | * @regs: JPEG IP registers mapping | ||
56 | * @irq: JPEG IP irq | ||
57 | * @clk: JPEG IP clock | ||
58 | * @dev: JPEG IP struct device | ||
59 | * @alloc_ctx: videobuf2 memory allocator's context | ||
60 | */ | ||
61 | struct s5p_jpeg { | ||
62 | struct mutex lock; | ||
63 | |||
64 | struct v4l2_device v4l2_dev; | ||
65 | struct video_device *vfd_encoder; | ||
66 | struct video_device *vfd_decoder; | ||
67 | struct v4l2_m2m_dev *m2m_dev; | ||
68 | |||
69 | struct resource *ioarea; | ||
70 | void __iomem *regs; | ||
71 | unsigned int irq; | ||
72 | struct clk *clk; | ||
73 | struct device *dev; | ||
74 | void *alloc_ctx; | ||
75 | }; | ||
76 | |||
77 | /** | ||
78 | * struct jpeg_fmt - driver's internal color format data | ||
79 | * @name: format descritpion | ||
80 | * @fourcc: the fourcc code, 0 if not applicable | ||
81 | * @depth: number of bits per pixel | ||
82 | * @colplanes: number of color planes (1 for packed formats) | ||
83 | * @h_align: horizontal alignment order (align to 2^h_align) | ||
84 | * @v_align: vertical alignment order (align to 2^v_align) | ||
85 | * @types: types of queue this format is applicable to | ||
86 | */ | ||
87 | struct s5p_jpeg_fmt { | ||
88 | char *name; | ||
89 | u32 fourcc; | ||
90 | int depth; | ||
91 | int colplanes; | ||
92 | int h_align; | ||
93 | int v_align; | ||
94 | u32 types; | ||
95 | }; | ||
96 | |||
97 | /** | ||
98 | * s5p_jpeg_q_data - parameters of one queue | ||
99 | * @fmt: driver-specific format of this queue | ||
100 | * @w: image width | ||
101 | * @h: image height | ||
102 | * @size: image buffer size in bytes | ||
103 | */ | ||
104 | struct s5p_jpeg_q_data { | ||
105 | struct s5p_jpeg_fmt *fmt; | ||
106 | u32 w; | ||
107 | u32 h; | ||
108 | u32 size; | ||
109 | }; | ||
110 | |||
111 | /** | ||
112 | * s5p_jpeg_ctx - the device context data | ||
113 | * @jpeg: JPEG IP device for this context | ||
114 | * @mode: compression (encode) operation or decompression (decode) | ||
115 | * @compr_quality: destination image quality in compression (encode) mode | ||
116 | * @m2m_ctx: mem2mem device context | ||
117 | * @out_q: source (output) queue information | ||
118 | * @cap_fmt: destination (capture) queue queue information | ||
119 | * @hdr_parsed: set if header has been parsed during decompression | ||
120 | */ | ||
121 | struct s5p_jpeg_ctx { | ||
122 | struct s5p_jpeg *jpeg; | ||
123 | unsigned int mode; | ||
124 | unsigned int compr_quality; | ||
125 | struct v4l2_m2m_ctx *m2m_ctx; | ||
126 | struct s5p_jpeg_q_data out_q; | ||
127 | struct s5p_jpeg_q_data cap_q; | ||
128 | bool hdr_parsed; | ||
129 | }; | ||
130 | |||
131 | /** | ||
132 | * s5p_jpeg_buffer - description of memory containing input JPEG data | ||
133 | * @size: buffer size | ||
134 | * @curr: current position in the buffer | ||
135 | * @data: pointer to the data | ||
136 | */ | ||
137 | struct s5p_jpeg_buffer { | ||
138 | unsigned long size; | ||
139 | unsigned long curr; | ||
140 | unsigned long data; | ||
141 | }; | ||
142 | |||
143 | #endif /* JPEG_CORE_H */ | ||