OMAP_VOUT: Allow omap_vout to build without VRFB
v2 cover OMAP_VOUT: Allow omap_vout to build without VRFB
Introduce omap_vout_vrfb.c and omap_vout_vrfb.h, for all VRFB related API's, making OMAP_VOUT driver independent from VRFB. This is required for OMAP4 DSS, since OMAP4 doesn't have VRFB block.
A new enum called vout_rotation_type is introduced to differentiate between no rotation and vrfb rotation. A member rotation_type is introduced in omapvideo_info, this allows to call vrfb specific functions only if the rotation type is VOUT_ROT_VRFB. When the rotation_type is set to VOUT_ROT_NONE, the S_CTRL ioctl prevents the user setting a non zero rotation or non zero mirror value.
Changes since v1:
- add a patch to make rotation related functions names more descriptive.
- remove unnecessary externs, add static to some local functions.
- improve patch description.
Archit Taneja (3):
OMAP_VOUT: CLEANUP: Move generic functions and macros to common files
OMAP_VOUT: CLEANUP: Make rotation related helper functions more
descriptive
OMAP_VOUT: Create separate file for VRFB related API's
drivers/media/video/omap/Kconfig | 7 +- drivers/media/video/omap/Makefile | 1 + drivers/media/video/omap/omap_vout.c | 582 +++++------------------------ drivers/media/video/omap/omap_vout_vrfb.c | 390 +++++++++++++++++++ drivers/media/video/omap/omap_vout_vrfb.h | 40 ++ drivers/media/video/omap/omap_voutdef.h | 78 ++++ drivers/media/video/omap/omap_voutlib.c | 46 +++ drivers/media/video/omap/omap_voutlib.h | 12 +- 8 files changed, 661 insertions(+), 495 deletions(-) create mode 100644 drivers/media/video/omap/omap_vout_vrfb.c create mode 100644 drivers/media/video/omap/omap_vout_vrfb.h
PATCH v2 1/3 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
--- drivers/media/video/omap/omap_vout.c | 117 +----------------------------- drivers/media/video/omap/omap_voutdef.h | 62 ++++++++++++++++ drivers/media/video/omap/omap_voutlib.c | 46 ++++++++++++ drivers/media/video/omap/omap_voutlib.h | 12 ++-- 4 files changed, 119 insertions(+), 118 deletions(-)
drivers/media/video/omap/omap_vout.c +4 -113
@@ -35,17 +35,14 @@#include <linux/sched.h> #include <linux/types.h> #include <linux/platform_device.h> -#include <linux/dma-mapping.h> #include <linux/irq.h> #include <linux/videodev2.h> -#include <linux/slab.h> #include <media/videobuf-dma-contig.h> #include <media/v4l2-device.h> #include <media/v4l2-ioctl.h> #include <plat/dma.h> -#include <plat/vram.h> #include <plat/vrfb.h> #include <video/omapdss.h>
@@ -56,7 +53,6 @@ MODULE_AUTHOR("Texas Instruments");MODULE_DESCRIPTION ("OMAP Video for Linux Video out driver" );MODULE_LICENSE ("GPL" ); -/* Driver Configuration macros */ #define VOUT_NAME "omap_vout"
@@ -65,31 +61,6 @@ enum omap_vout_channels { OMAP_VIDEO2, }; -enum dma_channel_state { -DMA_CHAN_NOT_ALLOTED , -DMA_CHAN_ALLOTED , -}; - -#define QQVGA_WIDTH 160 -#define QQVGA_HEIGHT 120 - -/* Max Resolution supported by the driver */ -#define VID_MAX_WIDTH 1280/* Largest width */ -#define VID_MAX_HEIGHT 720/* Largest height */ - -/* Mimimum requirement is 2x2 for DSS */ -#define VID_MIN_WIDTH 2 -#define VID_MIN_HEIGHT 2 - -/* 2048 x 2048 is max res supported by OMAP display controller */ -#define MAX_PIXELS_PER_LINE 2048 - -#define VRFB_TX_TIMEOUT 1000 -#define VRFB_NUM_BUFS 4 - -/* Max buffer size tobe allocated during init */ -#define OMAP_VOUT_MAX_BUF_SIZE (VID_MAX_WIDTH*VID_MAX_HEIGHT*4) -static struct videobuf_queue_ops video_vbq_ops;/* Variables configurable through module params*/ static u32 video1_numbuffers =3 ;
@@ -172,49 +143,6 @@ const static struct v4l2_fmtdesc omap_formats[] = {#define NUM_OUTPUT_FORMATS (ARRAY_SIZE(omap_formats))/* -* Allocate buffers -*/ -static unsigned long omap_vout_alloc_buffer (u32 buf_size,u32 *phys_addr) -{ -u32 order, size; -unsigned long virt_addr, addr; - - size =PAGE_ALIGN (buf_size); - order =get_order (size); - virt_addr =__get_free_pages (GFP_KERNEL , order); - addr = virt_addr; - -if (virt_addr) { -while (size >0 ) { -SetPageReserved (virt_to_page (addr)); - addr +=PAGE_SIZE ; - size -=PAGE_SIZE ; - } - } - *phys_addr = (u32 )virt_to_phys ((void *) virt_addr); -return virt_addr; -} - -/* -* Free buffers -*/ -static void omap_vout_free_buffer (unsigned long virtaddr,u32 buf_size) -{ -u32 order, size; -unsigned long addr = virtaddr; - - size =PAGE_ALIGN (buf_size); - order =get_order (size); - -while (size >0 ) { -ClearPageReserved (virt_to_page (addr)); - addr +=PAGE_SIZE ; - size -=PAGE_SIZE ; - } -free_pages ((unsigned long ) virtaddr, order); -} - -/* * Function for allocating video buffers */ 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) }/* -* Return true if rotation is 90 or 270 -*/ -static inline int rotate_90_or_270 (const struct omap_vout_device *vout) -{ -return (vout->rotation == dss_rotation_90_degree || - vout->rotation == dss_rotation_270_degree); -} - -/* -* Return true if rotation is enabled -*/ -static inline int rotation_enabled (const struct omap_vout_device *vout) -{ -return vout->rotation || vout->mirror; -} - -/* -* Reverse the rotation degree if mirroring is enabled -*/ -static inline int calc_rotation (const struct omap_vout_device *vout) -{ -if (!vout->mirror) -return vout->rotation; - -switch (vout->rotation) { -case dss_rotation_90_degree: -return dss_rotation_270_degree; -case dss_rotation_270_degree: -return dss_rotation_90_degree; -case dss_rotation_180_degree: -return dss_rotation_0_degree; -default : -return dss_rotation_180_degree; - } -} - -/* * Free the V4L2 buffers */ 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)/* * Setup the overlay */ -int omapvid_setup_overlay (struct omap_vout_device *vout, +static int omapvid_setup_overlay (struct omap_vout_device *vout,struct omap_overlay *ovl,int posx,int posy,int outw,int outh,u32 addr) {
@@ -744,7 +635,7 @@ setup_ovl_err:/* * Initialize the overlay structure */ -int omapvid_init (struct omap_vout_device *vout,u32 addr) +static int omapvid_init (struct omap_vout_device *vout,u32 addr) {int ret =0 , i;struct v4l2_window *win;
@@ -809,7 +700,7 @@ omapvid_init_err:/* * Apply the changes set the go bit of DSS */ -int omapvid_apply_changes (struct omap_vout_device *vout) +static int omapvid_apply_changes (struct omap_vout_device *vout) {int i;struct omap_overlay *ovl;
@@ -825,7 +716,7 @@ int omapvid_apply_changes(struct omap_vout_device *vout)return 0 ; } -void omap_vout_isr (void *arg,unsigned int irqstatus) +static void omap_vout_isr (void *arg,unsigned int irqstatus) {int ret;u32 addr, fid;
drivers/media/video/omap/omap_voutdef.h +62 -0
72 lines not on this page · raw message
drivers/media/video/omap/omap_voutlib.c +46 -0
57 lines not on this page · raw message
drivers/media/video/omap/omap_voutlib.h +7 -5
@@ -12,23 +12,25 @@#ifndef OMAP_VOUTLIB_H #define OMAP_VOUTLIB_H -extern void omap_vout_default_crop (struct v4l2_pix_format *pix, +void omap_vout_default_crop (struct v4l2_pix_format *pix,struct v4l2_framebuffer *fbuf,struct v4l2_rect *crop); -extern int omap_vout_new_crop (struct v4l2_pix_format *pix, +int omap_vout_new_crop (struct v4l2_pix_format *pix,struct v4l2_rect *crop,struct v4l2_window *win,struct v4l2_framebuffer *fbuf,const struct v4l2_rect *new_crop); -extern int omap_vout_try_window (struct v4l2_framebuffer *fbuf, +int omap_vout_try_window (struct v4l2_framebuffer *fbuf,struct v4l2_window *new_win); -extern int omap_vout_new_window (struct v4l2_rect *crop, +int omap_vout_new_window (struct v4l2_rect *crop,struct v4l2_window *win,struct v4l2_framebuffer *fbuf,struct v4l2_window *new_win); -extern void omap_vout_new_format (struct v4l2_pix_format *pix, +void omap_vout_new_format (struct v4l2_pix_format *pix,struct v4l2_framebuffer *fbuf,struct v4l2_rect *crop,struct v4l2_window *win); +unsigned long omap_vout_alloc_buffer (u32 buf_size,u32 *phys_addr); +void omap_vout_free_buffer (unsigned long virtaddr,u32 buf_size);#endif /* #ifndef OMAP_VOUTLIB_H */
Signature · 1 line
1.7.1
PATCH v2 2/3 OMAP_VOUT: CLEANUP: Make rotation related helper functions more descriptive
In reply to Archit TanejaRename rotation_enabled() and rotate_90_or_270() to is_rotation_enabled() and is_rotation_90_or_270() to make them more descriptive.
--- drivers/media/video/omap/omap_vout.c | 26 +++++++++++++------------- drivers/media/video/omap/omap_voutdef.h | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-)
drivers/media/video/omap/omap_vout.c +13 -13
@@ -343,7 +343,7 @@ static int omap_vout_vrfb_buffer_setup(struct omap_vout_device *vout,/* Allocate the VRFB buffers only if the buffers are not * allocated during init time. */ -if ((rotation_enabled (vout)) && !vout->vrfb_static_allocation) +if ((is_rotation_enabled (vout)) && !vout->vrfb_static_allocation)if (omap_vout_allocate_vrfb_buffers (vout, count, startindex))return -ENOMEM ;
@@ -419,7 +419,7 @@ static int omap_vout_calculate_offset(struct omap_vout_device *vout)if (V4L2_PIX_FMT_YUYV == pix->pixelformat ||V4L2_PIX_FMT_UYVY == pix->pixelformat) { -if (rotation_enabled (vout)) { +if (is_rotation_enabled (vout)) {/* * ps - Actual pixel size for YUYV/UYVY for * VRFB/Mirroring is 4 bytes
@@ -439,7 +439,7 @@ static int omap_vout_calculate_offset(struct omap_vout_device *vout) vout->ps = ps; vout->vr_ps = vr_ps; -if (rotation_enabled (vout)) { +if (is_rotation_enabled (vout)) { line_length =MAX_PIXELS_PER_LINE ; ctop = (pix->height - crop->height) - crop->top; cleft = (pix->width - crop->width) - crop->left;
@@ -578,7 +578,7 @@ static int omapvid_setup_overlay(struct omap_vout_device *vout,/* Setup the input plane parameters according to * rotation value selected. */ -if (rotate_90_or_270 (vout)) { +if (is_rotation_90_or_270 (vout)) { cropheight = vout->crop.width; cropwidth = vout->crop.height; pixheight = vout->pix.width;
@@ -602,7 +602,7 @@ static int omapvid_setup_overlay(struct omap_vout_device *vout, info.out_width = outw; info.out_height = outh; info.global_alpha = vout->win.global_alpha; -if (!rotation_enabled (vout)) { +if (!is_rotation_enabled (vout)) { info.rotation =0 ; info.rotation_type =OMAP_DSS_ROT_DMA ; info.screen_width = pixwidth;
@@ -857,11 +857,11 @@ static int omap_vout_buffer_setup(struct videobuf_queue *q, unsigned int *count,if (V4L2_MEMORY_MMAP == vout->memory && *count < startindex) *count = startindex; -if ((rotation_enabled (vout )) && *count >VRFB_NUM_BUFS ) +if ((is_rotation_enabled (vout )) && *count >VRFB_NUM_BUFS ) *count =VRFB_NUM_BUFS ;/* If rotation is enabled, allocate memory for VRFB space also */ -if (rotation_enabled (vout)) +if (is_rotation_enabled (vout))if (omap_vout_vrfb_buffer_setup (vout, count, startindex))return -ENOMEM ;
@@ -879,7 +879,7 @@ static int omap_vout_buffer_setup(struct videobuf_queue *q, unsigned int *count, virt_addr =omap_vout_alloc_buffer (vout->buffer_size, &phy_addr);if (!virt_addr) { -if (!rotation_enabled (vout)) +if (!is_rotation_enabled (vout))break ;/* Free the VRFB buffers if no space for V4L2 buffers */ for (j = i; j < *count; j++) {
@@ -973,7 +973,7 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q, vout->queued_buf_addr[vb->i] = (u8 *)vout->buf_phy_addr[vb->i]; } -if (!rotation_enabled (vout)) +if (!is_rotation_enabled (vout))return 0 ; dmabuf = vout->buf_phy_addr[vb->i];
@@ -1332,7 +1332,7 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *fh,/* We dont support RGB24-packed mode if vrfb rotation * is enabled*/ -if ((rotation_enabled (vout )) && +if ((is_rotation_enabled (vout )) && f->fmt.pix.pixelformat ==V4L2_PIX_FMT_RGB24 ) { ret = -EINVAL ; goto s_fmt_vid_out_exit;
@@ -1340,7 +1340,7 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *fh,/* get the framebuffer parameters */ -if (rotate_90_or_270 (vout)) { +if (is_rotation_90_or_270 (vout)) { vout->fbuf.fmt.height = timing->x_res; vout->fbuf.fmt.width = timing->y_res; }else {
@@ -1520,7 +1520,7 @@ static int vidioc_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)/* get the display device attached to the overlay */ timing = &ovl->manager->device->panel.timings; -if (rotate_90_or_270 (vout)) { +if (is_rotation_90_or_270 (vout)) { vout->fbuf.fmt.height = timing->x_res; vout->fbuf.fmt.width = timing->y_res; }else {
@@ -1768,7 +1768,7 @@ static int vidioc_qbuf(struct file *file, void *fh, } } -if ((rotation_enabled (vout )) && +if ((is_rotation_enabled (vout )) && vout->vrfb_dma_tx.req_status ==DMA_CHAN_NOT_ALLOTED ) {v4l2_warn (&vout->vid_dev->v4l2_dev,"DMA Channel not allocated for Rotation\n" );
drivers/media/video/omap/omap_voutdef.h +2 -2
@@ -173,7 +173,7 @@ struct omap_vout_device {/* * Return true if rotation is 90 or 270 */ -static inline int rotate_90_or_270 (const struct omap_vout_device *vout) +static inline int is_rotation_90_or_270 (const struct omap_vout_device *vout) {return (vout->rotation == dss_rotation_90_degree || vout->rotation == dss_rotation_270_degree);
@@ -182,7 +182,7 @@ static inline int rotate_90_or_270(const struct omap_vout_device *vout)/* * Return true if rotation is enabled */ -static inline int rotation_enabled (const struct omap_vout_device *vout) +static inline int is_rotation_enabled (const struct omap_vout_device *vout) {return vout->rotation || vout->mirror; }
Signature · 1 line
1.7.1
PATCH v2 3/3 OMAP_VOUT: Create separate file for VRFB related API's
In reply to Archit TanejaIntroduce omap_vout_vrfb.c and omap_vout_vrfb.h, for all VRFB related API's, making OMAP_VOUT driver independent from VRFB. This is required for OMAP4 DSS, since OMAP4 doesn't have VRFB block.
Added new enum vout_rotation_type and "rotation_type" member to omapvideo_info, this is initialized based on the arch type in omap_vout_probe. The rotation_type var is now used to choose between vrfb and non-vrfb calls.
--- drivers/media/video/omap/Kconfig | 7 +- drivers/media/video/omap/Makefile | 1 + drivers/media/video/omap/omap_vout.c | 453 ++++++----------------------- drivers/media/video/omap/omap_vout_vrfb.c | 390 +++++++++++++++++++++++++ drivers/media/video/omap/omap_vout_vrfb.h | 40 +++ drivers/media/video/omap/omap_voutdef.h | 16 + 6 files changed, 536 insertions(+), 371 deletions(-) create mode 100644 drivers/media/video/omap/omap_vout_vrfb.c create mode 100644 drivers/media/video/omap/omap_vout_vrfb.h
drivers/media/video/omap/Kconfig +5 -2
@@ -1,11 +1,14 @@ +config VIDEO_OMAP2_VOUT_VRFB + bool + config VIDEO_OMAP2_VOUT tristate "OMAP2/OMAP3 V4L2-Display driver" depends on ARCH_OMAP2 || ARCH_OMAP3 select VIDEOBUF_GEN select VIDEOBUF_DMA_CONTIG select OMAP2_DSS - select OMAP2_VRAM - select OMAP2_VRFB + select OMAP2_VRFB if ARCH_OMAP2 || ARCH_OMAP3 + select VIDEO_OMAP2_VOUT_VRFB if VIDEO_OMAP2_VOUT && OMAP2_VRFB default n ---help--- V4L2 Display driver support for OMAP2/3 based boards.
drivers/media/video/omap/Makefile +1 -0
@@ -4,4 +4,5 @@ # OMAP2/3 Display driver omap-vout-y := omap_vout.o omap_voutlib.o +omap-vout-$(CONFIG_VIDEO_OMAP2_VOUT_VRFB) += omap_vout_vrfb.o obj-$(CONFIG_VIDEO_OMAP2_VOUT) += omap-vout.o
drivers/media/video/omap/omap_vout.c +85 -370
635 lines not on this page · raw message
drivers/media/video/omap/omap_vout_vrfb.c new file +390 -0
390 lines not on this page · raw message
drivers/media/video/omap/omap_vout_vrfb.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* omap_vout_vrfb.h +* +* Copyright (C) 2010 Texas Instruments. +* +* This file is licensed under the terms of the GNU General Public License +* version 2. This program is licensed "as is" without any warranty of any +* kind, whether express or implied. +* +*/ + +#ifndef OMAP_VOUT_VRFB_H +#define OMAP_VOUT_VRFB_H + +#ifdef CONFIG_VIDEO_OMAP2_VOUT_VRFB +void omap_vout_free_vrfb_buffers (struct omap_vout_device *vout); +int omap_vout_setup_vrfb_bufs (struct platform_device *pdev,int vid_num, +u32 static_vrfb_allocation); +void omap_vout_release_vrfb (struct omap_vout_device *vout); +int omap_vout_vrfb_buffer_setup (struct omap_vout_device *vout, +unsigned int *count,unsigned int startindex); +int omap_vout_prepare_vrfb (struct omap_vout_device *vout, +struct videobuf_buffer *vb); +void omap_vout_calculate_vrfb_offset (struct omap_vout_device *vout); +#else +void omap_vout_free_vrfb_buffers (struct omap_vout_device *vout) { } +int omap_vout_setup_vrfb_bufs (struct platform_device *pdev,int vid_num, +u32 static_vrfb_allocation) + {return 0 ; } +void omap_vout_release_vrfb (struct omap_vout_device *vout) { } +int omap_vout_vrfb_buffer_setup (struct omap_vout_device *vout, +unsigned int *count,unsigned int startindex) + {return 0 ; } +int omap_vout_prepare_vrfb (struct omap_vout_device *vout, +struct videobuf_buffer *vb) + {return 0 ; } +void omap_vout_calculate_vrfb_offset (struct omap_vout_device *vout) { } +#endif + +#endif
drivers/media/video/omap/omap_voutdef.h +16 -0
@@ -12,6 +12,7 @@#define OMAP_VOUTDEF_H #include <video/omapdss.h> +#include <plat/vrfb.h> #define YUYV_BPP 2#define RGB565_BPP 2
@@ -62,6 +63,18 @@ enum dss_rotation { dss_rotation_180_degree =2 , dss_rotation_270_degree = 3, }; + +/* Enum for choosing rotation type for vout +* DSS2 doesn't understand no rotation as an +* option while V4L2 driver doesn't support +* rotation in the case where VRFB is not built in +* the kernel +*/ +enum vout_rotaion_type { +VOUT_ROT_NONE =0 , +VOUT_ROT_VRFB =1 , +}; +/* * This structure is used to store the DMA transfer parameters * for VRFB hidden buffer
@@ -78,6 +91,7 @@ struct omapvideo_info {int id;int num_overlays;struct omap_overlay *overlays[MAX_OVLS ]; +enum vout_rotaion_type rotation_type; };struct omap2video_device {
@@ -206,4 +220,6 @@ static inline int calc_rotation(const struct omap_vout_device *vout) return dss_rotation_180_degree; } } + +void omap_vout_free_buffers (struct omap_vout_device *vout);#endif /* ifndef OMAP_VOUTDEF_H */
Signature · 1 line
1.7.1