diff options
author | archit taneja <archit@ti.com> | 2011-06-14 02:54:45 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-27 16:56:05 -0400 |
commit | a137ac870ba7df53e0c68cf2af2c79a71a2050c0 (patch) | |
tree | 6a5eb70143928deaaa4aa0a7fa4137e4a19ad4f8 /drivers/media | |
parent | e213e438ce2a7451572f1c00ed87893ca25d3ea9 (diff) |
[media] OMAP_VOUT: CLEANUP: Move generic functions and macros to common files
Move the inline functions rotate_90_or_270(), rotation_enabled(), and
calc_rotation() from omap_vout.c to omap_voutdef.h.
Move the independent functions omap_vout_alloc_buffer() and
omap_vout_free_buffer() to omap_voutlib.c.
Remove extern identifier from function definitions in omap_voutlib.h
Add static identifier to functions that are used locally in omap_vout.c
Signed-off-by: Archit Taneja <archit@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/omap/omap_vout.c | 117 | ||||
-rw-r--r-- | drivers/media/video/omap/omap_voutdef.h | 62 | ||||
-rw-r--r-- | drivers/media/video/omap/omap_voutlib.c | 46 | ||||
-rw-r--r-- | drivers/media/video/omap/omap_voutlib.h | 12 |
4 files changed, 119 insertions, 118 deletions
diff --git a/drivers/media/video/omap/omap_vout.c b/drivers/media/video/omap/omap_vout.c index cb70ff139d8f..131aff634580 100644 --- a/drivers/media/video/omap/omap_vout.c +++ b/drivers/media/video/omap/omap_vout.c | |||
@@ -35,17 +35,14 @@ | |||
35 | #include <linux/sched.h> | 35 | #include <linux/sched.h> |
36 | #include <linux/types.h> | 36 | #include <linux/types.h> |
37 | #include <linux/platform_device.h> | 37 | #include <linux/platform_device.h> |
38 | #include <linux/dma-mapping.h> | ||
39 | #include <linux/irq.h> | 38 | #include <linux/irq.h> |
40 | #include <linux/videodev2.h> | 39 | #include <linux/videodev2.h> |
41 | #include <linux/slab.h> | ||
42 | 40 | ||
43 | #include <media/videobuf-dma-contig.h> | 41 | #include <media/videobuf-dma-contig.h> |
44 | #include <media/v4l2-device.h> | 42 | #include <media/v4l2-device.h> |
45 | #include <media/v4l2-ioctl.h> | 43 | #include <media/v4l2-ioctl.h> |
46 | 44 | ||
47 | #include <plat/dma.h> | 45 | #include <plat/dma.h> |
48 | #include <plat/vram.h> | ||
49 | #include <plat/vrfb.h> | 46 | #include <plat/vrfb.h> |
50 | #include <video/omapdss.h> | 47 | #include <video/omapdss.h> |
51 | 48 | ||
@@ -56,7 +53,6 @@ MODULE_AUTHOR("Texas Instruments"); | |||
56 | MODULE_DESCRIPTION("OMAP Video for Linux Video out driver"); | 53 | MODULE_DESCRIPTION("OMAP Video for Linux Video out driver"); |
57 | MODULE_LICENSE("GPL"); | 54 | MODULE_LICENSE("GPL"); |
58 | 55 | ||
59 | |||
60 | /* Driver Configuration macros */ | 56 | /* Driver Configuration macros */ |
61 | #define VOUT_NAME "omap_vout" | 57 | #define VOUT_NAME "omap_vout" |
62 | 58 | ||
@@ -65,31 +61,6 @@ enum omap_vout_channels { | |||
65 | OMAP_VIDEO2, | 61 | OMAP_VIDEO2, |
66 | }; | 62 | }; |
67 | 63 | ||
68 | enum dma_channel_state { | ||
69 | DMA_CHAN_NOT_ALLOTED, | ||
70 | DMA_CHAN_ALLOTED, | ||
71 | }; | ||
72 | |||
73 | #define QQVGA_WIDTH 160 | ||
74 | #define QQVGA_HEIGHT 120 | ||
75 | |||
76 | /* Max Resolution supported by the driver */ | ||
77 | #define VID_MAX_WIDTH 1280 /* Largest width */ | ||
78 | #define VID_MAX_HEIGHT 720 /* Largest height */ | ||
79 | |||
80 | /* Mimimum requirement is 2x2 for DSS */ | ||
81 | #define VID_MIN_WIDTH 2 | ||
82 | #define VID_MIN_HEIGHT 2 | ||
83 | |||
84 | /* 2048 x 2048 is max res supported by OMAP display controller */ | ||
85 | #define MAX_PIXELS_PER_LINE 2048 | ||
86 | |||
87 | #define VRFB_TX_TIMEOUT 1000 | ||
88 | #define VRFB_NUM_BUFS 4 | ||
89 | |||
90 | /* Max buffer size tobe allocated during init */ | ||
91 | #define OMAP_VOUT_MAX_BUF_SIZE (VID_MAX_WIDTH*VID_MAX_HEIGHT*4) | ||
92 | |||
93 | static struct videobuf_queue_ops video_vbq_ops; | 64 | static struct videobuf_queue_ops video_vbq_ops; |
94 | /* Variables configurable through module params*/ | 65 | /* Variables configurable through module params*/ |
95 | static u32 video1_numbuffers = 3; | 66 | static u32 video1_numbuffers = 3; |
@@ -172,49 +143,6 @@ static const struct v4l2_fmtdesc omap_formats[] = { | |||
172 | #define NUM_OUTPUT_FORMATS (ARRAY_SIZE(omap_formats)) | 143 | #define NUM_OUTPUT_FORMATS (ARRAY_SIZE(omap_formats)) |
173 | 144 | ||
174 | /* | 145 | /* |
175 | * Allocate buffers | ||
176 | */ | ||
177 | static unsigned long omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr) | ||
178 | { | ||
179 | u32 order, size; | ||
180 | unsigned long virt_addr, addr; | ||
181 | |||
182 | size = PAGE_ALIGN(buf_size); | ||
183 | order = get_order(size); | ||
184 | virt_addr = __get_free_pages(GFP_KERNEL, order); | ||
185 | addr = virt_addr; | ||
186 | |||
187 | if (virt_addr) { | ||
188 | while (size > 0) { | ||
189 | SetPageReserved(virt_to_page(addr)); | ||
190 | addr += PAGE_SIZE; | ||
191 | size -= PAGE_SIZE; | ||
192 | } | ||
193 | } | ||
194 | *phys_addr = (u32) virt_to_phys((void *) virt_addr); | ||
195 | return virt_addr; | ||
196 | } | ||
197 | |||
198 | /* | ||
199 | * Free buffers | ||
200 | */ | ||
201 | static void omap_vout_free_buffer(unsigned long virtaddr, u32 buf_size) | ||
202 | { | ||
203 | u32 order, size; | ||
204 | unsigned long addr = virtaddr; | ||
205 | |||
206 | size = PAGE_ALIGN(buf_size); | ||
207 | order = get_order(size); | ||
208 | |||
209 | while (size > 0) { | ||
210 | ClearPageReserved(virt_to_page(addr)); | ||
211 | addr += PAGE_SIZE; | ||
212 | size -= PAGE_SIZE; | ||
213 | } | ||
214 | free_pages((unsigned long) virtaddr, order); | ||
215 | } | ||
216 | |||
217 | /* | ||
218 | * Function for allocating video buffers | 146 | * Function for allocating video buffers |
219 | */ | 147 | */ |
220 | static int omap_vout_allocate_vrfb_buffers(struct omap_vout_device *vout, | 148 | static int omap_vout_allocate_vrfb_buffers(struct omap_vout_device *vout, |
@@ -369,43 +297,6 @@ static void omap_vout_release_vrfb(struct omap_vout_device *vout) | |||
369 | } | 297 | } |
370 | 298 | ||
371 | /* | 299 | /* |
372 | * Return true if rotation is 90 or 270 | ||
373 | */ | ||
374 | static inline int rotate_90_or_270(const struct omap_vout_device *vout) | ||
375 | { | ||
376 | return (vout->rotation == dss_rotation_90_degree || | ||
377 | vout->rotation == dss_rotation_270_degree); | ||
378 | } | ||
379 | |||
380 | /* | ||
381 | * Return true if rotation is enabled | ||
382 | */ | ||
383 | static inline int rotation_enabled(const struct omap_vout_device *vout) | ||
384 | { | ||
385 | return vout->rotation || vout->mirror; | ||
386 | } | ||
387 | |||
388 | /* | ||
389 | * Reverse the rotation degree if mirroring is enabled | ||
390 | */ | ||
391 | static inline int calc_rotation(const struct omap_vout_device *vout) | ||
392 | { | ||
393 | if (!vout->mirror) | ||
394 | return vout->rotation; | ||
395 | |||
396 | switch (vout->rotation) { | ||
397 | case dss_rotation_90_degree: | ||
398 | return dss_rotation_270_degree; | ||
399 | case dss_rotation_270_degree: | ||
400 | return dss_rotation_90_degree; | ||
401 | case dss_rotation_180_degree: | ||
402 | return dss_rotation_0_degree; | ||
403 | default: | ||
404 | return dss_rotation_180_degree; | ||
405 | } | ||
406 | } | ||
407 | |||
408 | /* | ||
409 | * Free the V4L2 buffers | 300 | * Free the V4L2 buffers |
410 | */ | 301 | */ |
411 | static void omap_vout_free_buffers(struct omap_vout_device *vout) | 302 | static void omap_vout_free_buffers(struct omap_vout_device *vout) |
@@ -664,7 +555,7 @@ static int video_mode_to_dss_mode(struct omap_vout_device *vout) | |||
664 | /* | 555 | /* |
665 | * Setup the overlay | 556 | * Setup the overlay |
666 | */ | 557 | */ |
667 | int omapvid_setup_overlay(struct omap_vout_device *vout, | 558 | static int omapvid_setup_overlay(struct omap_vout_device *vout, |
668 | struct omap_overlay *ovl, int posx, int posy, int outw, | 559 | struct omap_overlay *ovl, int posx, int posy, int outw, |
669 | int outh, u32 addr) | 560 | int outh, u32 addr) |
670 | { | 561 | { |
@@ -744,7 +635,7 @@ setup_ovl_err: | |||
744 | /* | 635 | /* |
745 | * Initialize the overlay structure | 636 | * Initialize the overlay structure |
746 | */ | 637 | */ |
747 | int omapvid_init(struct omap_vout_device *vout, u32 addr) | 638 | static int omapvid_init(struct omap_vout_device *vout, u32 addr) |
748 | { | 639 | { |
749 | int ret = 0, i; | 640 | int ret = 0, i; |
750 | struct v4l2_window *win; | 641 | struct v4l2_window *win; |
@@ -809,7 +700,7 @@ omapvid_init_err: | |||
809 | /* | 700 | /* |
810 | * Apply the changes set the go bit of DSS | 701 | * Apply the changes set the go bit of DSS |
811 | */ | 702 | */ |
812 | int omapvid_apply_changes(struct omap_vout_device *vout) | 703 | static int omapvid_apply_changes(struct omap_vout_device *vout) |
813 | { | 704 | { |
814 | int i; | 705 | int i; |
815 | struct omap_overlay *ovl; | 706 | struct omap_overlay *ovl; |
@@ -825,7 +716,7 @@ int omapvid_apply_changes(struct omap_vout_device *vout) | |||
825 | return 0; | 716 | return 0; |
826 | } | 717 | } |
827 | 718 | ||
828 | void omap_vout_isr(void *arg, unsigned int irqstatus) | 719 | static void omap_vout_isr(void *arg, unsigned int irqstatus) |
829 | { | 720 | { |
830 | int ret; | 721 | int ret; |
831 | u32 addr, fid; | 722 | u32 addr, fid; |
diff --git a/drivers/media/video/omap/omap_voutdef.h b/drivers/media/video/omap/omap_voutdef.h index 659497b84996..31e6261b2c49 100644 --- a/drivers/media/video/omap/omap_voutdef.h +++ b/drivers/media/video/omap/omap_voutdef.h | |||
@@ -27,6 +27,31 @@ | |||
27 | #define MAX_DISPLAYS 3 | 27 | #define MAX_DISPLAYS 3 |
28 | #define MAX_MANAGERS 3 | 28 | #define MAX_MANAGERS 3 |
29 | 29 | ||
30 | #define QQVGA_WIDTH 160 | ||
31 | #define QQVGA_HEIGHT 120 | ||
32 | |||
33 | /* Max Resolution supported by the driver */ | ||
34 | #define VID_MAX_WIDTH 1280 /* Largest width */ | ||
35 | #define VID_MAX_HEIGHT 720 /* Largest height */ | ||
36 | |||
37 | /* Mimimum requirement is 2x2 for DSS */ | ||
38 | #define VID_MIN_WIDTH 2 | ||
39 | #define VID_MIN_HEIGHT 2 | ||
40 | |||
41 | /* 2048 x 2048 is max res supported by OMAP display controller */ | ||
42 | #define MAX_PIXELS_PER_LINE 2048 | ||
43 | |||
44 | #define VRFB_TX_TIMEOUT 1000 | ||
45 | #define VRFB_NUM_BUFS 4 | ||
46 | |||
47 | /* Max buffer size tobe allocated during init */ | ||
48 | #define OMAP_VOUT_MAX_BUF_SIZE (VID_MAX_WIDTH*VID_MAX_HEIGHT*4) | ||
49 | |||
50 | enum dma_channel_state { | ||
51 | DMA_CHAN_NOT_ALLOTED, | ||
52 | DMA_CHAN_ALLOTED, | ||
53 | }; | ||
54 | |||
30 | /* Enum for Rotation | 55 | /* Enum for Rotation |
31 | * DSS understands rotation in 0, 1, 2, 3 context | 56 | * DSS understands rotation in 0, 1, 2, 3 context |
32 | * while V4L2 driver understands it as 0, 90, 180, 270 | 57 | * while V4L2 driver understands it as 0, 90, 180, 270 |
@@ -144,4 +169,41 @@ struct omap_vout_device { | |||
144 | int io_allowed; | 169 | int io_allowed; |
145 | 170 | ||
146 | }; | 171 | }; |
172 | |||
173 | /* | ||
174 | * Return true if rotation is 90 or 270 | ||
175 | */ | ||
176 | static inline int rotate_90_or_270(const struct omap_vout_device *vout) | ||
177 | { | ||
178 | return (vout->rotation == dss_rotation_90_degree || | ||
179 | vout->rotation == dss_rotation_270_degree); | ||
180 | } | ||
181 | |||
182 | /* | ||
183 | * Return true if rotation is enabled | ||
184 | */ | ||
185 | static inline int rotation_enabled(const struct omap_vout_device *vout) | ||
186 | { | ||
187 | return vout->rotation || vout->mirror; | ||
188 | } | ||
189 | |||
190 | /* | ||
191 | * Reverse the rotation degree if mirroring is enabled | ||
192 | */ | ||
193 | static inline int calc_rotation(const struct omap_vout_device *vout) | ||
194 | { | ||
195 | if (!vout->mirror) | ||
196 | return vout->rotation; | ||
197 | |||
198 | switch (vout->rotation) { | ||
199 | case dss_rotation_90_degree: | ||
200 | return dss_rotation_270_degree; | ||
201 | case dss_rotation_270_degree: | ||
202 | return dss_rotation_90_degree; | ||
203 | case dss_rotation_180_degree: | ||
204 | return dss_rotation_0_degree; | ||
205 | default: | ||
206 | return dss_rotation_180_degree; | ||
207 | } | ||
208 | } | ||
147 | #endif /* ifndef OMAP_VOUTDEF_H */ | 209 | #endif /* ifndef OMAP_VOUTDEF_H */ |
diff --git a/drivers/media/video/omap/omap_voutlib.c b/drivers/media/video/omap/omap_voutlib.c index 8ae74817a110..115408b9274f 100644 --- a/drivers/media/video/omap/omap_voutlib.c +++ b/drivers/media/video/omap/omap_voutlib.c | |||
@@ -24,8 +24,12 @@ | |||
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <linux/videodev2.h> | 25 | #include <linux/videodev2.h> |
26 | 26 | ||
27 | #include <linux/dma-mapping.h> | ||
28 | |||
27 | #include <plat/cpu.h> | 29 | #include <plat/cpu.h> |
28 | 30 | ||
31 | #include "omap_voutlib.h" | ||
32 | |||
29 | MODULE_AUTHOR("Texas Instruments"); | 33 | MODULE_AUTHOR("Texas Instruments"); |
30 | MODULE_DESCRIPTION("OMAP Video library"); | 34 | MODULE_DESCRIPTION("OMAP Video library"); |
31 | MODULE_LICENSE("GPL"); | 35 | MODULE_LICENSE("GPL"); |
@@ -291,3 +295,45 @@ void omap_vout_new_format(struct v4l2_pix_format *pix, | |||
291 | } | 295 | } |
292 | EXPORT_SYMBOL_GPL(omap_vout_new_format); | 296 | EXPORT_SYMBOL_GPL(omap_vout_new_format); |
293 | 297 | ||
298 | /* | ||
299 | * Allocate buffers | ||
300 | */ | ||
301 | unsigned long omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr) | ||
302 | { | ||
303 | u32 order, size; | ||
304 | unsigned long virt_addr, addr; | ||
305 | |||
306 | size = PAGE_ALIGN(buf_size); | ||
307 | order = get_order(size); | ||
308 | virt_addr = __get_free_pages(GFP_KERNEL, order); | ||
309 | addr = virt_addr; | ||
310 | |||
311 | if (virt_addr) { | ||
312 | while (size > 0) { | ||
313 | SetPageReserved(virt_to_page(addr)); | ||
314 | addr += PAGE_SIZE; | ||
315 | size -= PAGE_SIZE; | ||
316 | } | ||
317 | } | ||
318 | *phys_addr = (u32) virt_to_phys((void *) virt_addr); | ||
319 | return virt_addr; | ||
320 | } | ||
321 | |||
322 | /* | ||
323 | * Free buffers | ||
324 | */ | ||
325 | void omap_vout_free_buffer(unsigned long virtaddr, u32 buf_size) | ||
326 | { | ||
327 | u32 order, size; | ||
328 | unsigned long addr = virtaddr; | ||
329 | |||
330 | size = PAGE_ALIGN(buf_size); | ||
331 | order = get_order(size); | ||
332 | |||
333 | while (size > 0) { | ||
334 | ClearPageReserved(virt_to_page(addr)); | ||
335 | addr += PAGE_SIZE; | ||
336 | size -= PAGE_SIZE; | ||
337 | } | ||
338 | free_pages((unsigned long) virtaddr, order); | ||
339 | } | ||
diff --git a/drivers/media/video/omap/omap_voutlib.h b/drivers/media/video/omap/omap_voutlib.h index a60b16e8bfc3..e51750a597e3 100644 --- a/drivers/media/video/omap/omap_voutlib.h +++ b/drivers/media/video/omap/omap_voutlib.h | |||
@@ -12,23 +12,25 @@ | |||
12 | #ifndef OMAP_VOUTLIB_H | 12 | #ifndef OMAP_VOUTLIB_H |
13 | #define OMAP_VOUTLIB_H | 13 | #define OMAP_VOUTLIB_H |
14 | 14 | ||
15 | extern void omap_vout_default_crop(struct v4l2_pix_format *pix, | 15 | void omap_vout_default_crop(struct v4l2_pix_format *pix, |
16 | struct v4l2_framebuffer *fbuf, struct v4l2_rect *crop); | 16 | struct v4l2_framebuffer *fbuf, struct v4l2_rect *crop); |
17 | 17 | ||
18 | extern int omap_vout_new_crop(struct v4l2_pix_format *pix, | 18 | int omap_vout_new_crop(struct v4l2_pix_format *pix, |
19 | struct v4l2_rect *crop, struct v4l2_window *win, | 19 | struct v4l2_rect *crop, struct v4l2_window *win, |
20 | struct v4l2_framebuffer *fbuf, | 20 | struct v4l2_framebuffer *fbuf, |
21 | const struct v4l2_rect *new_crop); | 21 | const struct v4l2_rect *new_crop); |
22 | 22 | ||
23 | extern int omap_vout_try_window(struct v4l2_framebuffer *fbuf, | 23 | int omap_vout_try_window(struct v4l2_framebuffer *fbuf, |
24 | struct v4l2_window *new_win); | 24 | struct v4l2_window *new_win); |
25 | 25 | ||
26 | extern int omap_vout_new_window(struct v4l2_rect *crop, | 26 | int omap_vout_new_window(struct v4l2_rect *crop, |
27 | struct v4l2_window *win, struct v4l2_framebuffer *fbuf, | 27 | struct v4l2_window *win, struct v4l2_framebuffer *fbuf, |
28 | struct v4l2_window *new_win); | 28 | struct v4l2_window *new_win); |
29 | 29 | ||
30 | extern void omap_vout_new_format(struct v4l2_pix_format *pix, | 30 | void omap_vout_new_format(struct v4l2_pix_format *pix, |
31 | struct v4l2_framebuffer *fbuf, struct v4l2_rect *crop, | 31 | struct v4l2_framebuffer *fbuf, struct v4l2_rect *crop, |
32 | struct v4l2_window *win); | 32 | struct v4l2_window *win); |
33 | unsigned long omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr); | ||
34 | void omap_vout_free_buffer(unsigned long virtaddr, u32 buf_size); | ||
33 | #endif /* #ifndef OMAP_VOUTLIB_H */ | 35 | #endif /* #ifndef OMAP_VOUTLIB_H */ |
34 | 36 | ||