diff options
-rw-r--r-- | drivers/media/video/samsung/fimc/csis.c | 7 | ||||
-rw-r--r-- | drivers/media/video/samsung/fimc/csis.h | 6 | ||||
-rw-r--r-- | drivers/media/video/samsung/fimc/fimc-ipc.h | 6 | ||||
-rw-r--r-- | drivers/media/video/samsung/fimc/fimc.h | 201 | ||||
-rw-r--r-- | drivers/media/video/samsung/fimc/fimc_capture.c | 424 | ||||
-rw-r--r-- | drivers/media/video/samsung/fimc/fimc_dev.c | 58 | ||||
-rw-r--r-- | drivers/media/video/samsung/fimc/fimc_output.c | 206 | ||||
-rw-r--r-- | drivers/media/video/samsung/fimc/fimc_regs.c | 57 | ||||
-rw-r--r-- | drivers/media/video/samsung/fimc/ipc_table.h | 6 |
9 files changed, 555 insertions, 416 deletions
diff --git a/drivers/media/video/samsung/fimc/csis.c b/drivers/media/video/samsung/fimc/csis.c index 390fd68..f512d10 100644 --- a/drivers/media/video/samsung/fimc/csis.c +++ b/drivers/media/video/samsung/fimc/csis.c @@ -1,7 +1,7 @@ /* linux/drivers/media/video/samsung/csis.c * * Copyright (c) 2010 Samsung Electronics Co,. Ltd. - * http://www.samsung.com/ + * http://www.samsung.com/ * * MIPI-CSI2 Support file for FIMC driver * @@ -210,7 +210,8 @@ static void s3c_csis_set_hs_settle(int settle) } #endif -void s3c_csis_start(int lanes, int settle, int align, int width, int height, int pixel_format) +void s3c_csis_start(int lanes, int settle, int align, int width, + int height, int pixel_format) { struct platform_device *pdev = to_platform_device(s3c_csis->dev); struct s3c_platform_csis *pdata; @@ -227,7 +228,7 @@ void s3c_csis_start(int lanes, int settle, int align, int width, int height, int s3c_csis_set_hs_settle(settle); /* s5k6aa */ s3c_csis_set_data_align(align); s3c_csis_set_wclk(0); - if (pixel_format == V4L2_PIX_FMT_JPEG) + if (pixel_format == V4L2_PIX_FMT_JPEG) s3c_csis_set_format(MIPI_USER_DEF_PACKET_1); else s3c_csis_set_format(MIPI_CSI_YCBCR422_8BIT); diff --git a/drivers/media/video/samsung/fimc/csis.h b/drivers/media/video/samsung/fimc/csis.h index efd6892..4943c8f 100644 --- a/drivers/media/video/samsung/fimc/csis.h +++ b/drivers/media/video/samsung/fimc/csis.h @@ -1,7 +1,7 @@ /* linux/drivers/media/video/samsung/csis.h * * Copyright (c) 2010 Samsung Electronics Co,. Ltd. - * http://www.samsung.com/ + * http://www.samsung.com/ * * Header file for Samsung MIPI-CSI2 driver * @@ -30,10 +30,10 @@ enum mipi_format { }; struct s3c_csis_info { - char name[16]; + char name[16]; struct device *dev; struct clk *clock; - struct regulator *regulator; + struct regulator *regulator; void __iomem *regs; int irq; int nr_lanes; diff --git a/drivers/media/video/samsung/fimc/fimc-ipc.h b/drivers/media/video/samsung/fimc/fimc-ipc.h index 8e85d6e..e6182e7 100644 --- a/drivers/media/video/samsung/fimc/fimc-ipc.h +++ b/drivers/media/video/samsung/fimc/fimc-ipc.h @@ -133,9 +133,9 @@ struct ipc_control { void __iomem *regs; struct clk *clk; struct device *dev; - struct ipc_source src; - struct ipc_destination dst; - struct ipc_controlvariable control_var; + struct ipc_source src; + struct ipc_destination dst; + struct ipc_controlvariable control_var; struct ipc_enhancingvariable enhance_var; }; diff --git a/drivers/media/video/samsung/fimc/fimc.h b/drivers/media/video/samsung/fimc/fimc.h index 5d79a15..8e47805 100644 --- a/drivers/media/video/samsung/fimc/fimc.h +++ b/drivers/media/video/samsung/fimc/fimc.h @@ -111,12 +111,18 @@ enum fimc_input { }; enum fimc_overlay_mode { - FIMC_OVLY_NOT_FIXED = 0x0, /* Overlay mode isn't fixed. */ - FIMC_OVLY_FIFO = 0x1, /* Non-destructive Overlay with FIFO */ - FIMC_OVLY_DMA_AUTO = 0x2, /* Non-destructive Overlay with DMA */ - FIMC_OVLY_DMA_MANUAL = 0x3, /* Non-destructive Overlay with DMA */ - FIMC_OVLY_NONE_SINGLE_BUF = 0x4, /* Destructive Overlay with DMA single destination buffer */ - FIMC_OVLY_NONE_MULTI_BUF = 0x5, /* Destructive Overlay with DMA multiple dstination buffer */ + /* Overlay mode isn't fixed. */ + FIMC_OVLY_NOT_FIXED = 0x0, + /* Non-destructive Overlay with FIFO */ + FIMC_OVLY_FIFO = 0x1, + /* Non-destructive Overlay with DMA */ + FIMC_OVLY_DMA_AUTO = 0x2, + /* Non-destructive Overlay with DMA */ + FIMC_OVLY_DMA_MANUAL = 0x3, + /* Destructive Overlay with DMA single destination buffer */ + FIMC_OVLY_NONE_SINGLE_BUF = 0x4, + /* Destructive Overlay with DMA multiple dstination buffer */ + FIMC_OVLY_NONE_MULTI_BUF = 0x5, }; enum fimc_autoload { @@ -231,7 +237,7 @@ struct fimc_scaler { struct fimc_ctx { u32 ctx_num; struct v4l2_cropcap cropcap; - struct v4l2_rect crop; + struct v4l2_rect crop; struct v4l2_pix_format pix; struct v4l2_window win; struct v4l2_framebuffer fbuf; @@ -334,7 +340,7 @@ struct fimc_control { atomic_t in_use; void __iomem *regs; /* register i/o */ struct clk *clk; /* interface clock */ - struct regulator *regulator; /* pd regulator */ + struct regulator *regulator; /* pd regulator */ struct fimc_meminfo mem; /* for reserved mem */ /* kernel helpers */ @@ -360,15 +366,15 @@ struct fimc_control { enum fimc_status status; enum fimc_log log; - u32 ctx_busy[FIMC_MAX_CTXS]; + u32 ctx_busy[FIMC_MAX_CTXS]; }; /* global */ struct fimc_global { - struct fimc_control ctrl[FIMC_DEVICES]; + struct fimc_control ctrl[FIMC_DEVICES]; struct s3c_platform_camera camera[FIMC_MAXCAMS]; int camera_isvalid[FIMC_MAXCAMS]; - int active_camera; + int active_camera; int initialized; }; @@ -435,13 +441,19 @@ extern struct fimc_limit fimc50_limits[FIMC_DEVICES]; /* FIMD */ extern int s3cfb_direct_ioctl(int id, unsigned int cmd, unsigned long arg); -extern int s3cfb_open_fifo(int id, int ch, int (*do_priv)(void *), void *param); +extern int s3cfb_open_fifo(int id, int ch, + int (*do_priv)(void *), void *param); extern int s3cfb_close_fifo(int id, int (*do_priv)(void *), void *param); /* general */ -extern void s3c_csis_start(int lanes, int settle, int align, int width, int height, int pixel_format); -extern int fimc_dma_alloc(struct fimc_control *ctrl, struct fimc_buf_set *bs, int i, int align); -extern void fimc_dma_free(struct fimc_control *ctrl, struct fimc_buf_set *bs, int i); +extern void s3c_csis_start(int lanes, int settle, int align, + int width, int height, + int pixel_format); +extern int fimc_dma_alloc(struct fimc_control *ctrl, + struct fimc_buf_set *bs, + int i, int align); +extern void fimc_dma_free(struct fimc_control *ctrl, + struct fimc_buf_set *bs, int i); extern u32 fimc_mapping_rot_flip(u32 rot, u32 flip); extern int fimc_get_scaler_factor(u32 src, u32 tar, u32 *ratio, u32 *shift); extern void fimc_get_nv12t_size(int img_hres, int img_vres, @@ -452,13 +464,18 @@ extern void fimc_clk_en(struct fimc_control *ctrl, bool on); extern int fimc_select_camera(struct fimc_control *ctrl); /* capture device */ -extern int fimc_enum_input(struct file *file, void *fh, struct v4l2_input *inp); +extern int fimc_enum_input(struct file *file, void *fh, + struct v4l2_input *inp); extern int fimc_g_input(struct file *file, void *fh, unsigned int *i); extern int fimc_s_input(struct file *file, void *fh, unsigned int i); -extern int fimc_enum_fmt_vid_capture(struct file *file, void *fh, struct v4l2_fmtdesc *f); -extern int fimc_g_fmt_vid_capture(struct file *file, void *fh, struct v4l2_format *f); -extern int fimc_s_fmt_vid_capture(struct file *file, void *fh, struct v4l2_format *f); -extern int fimc_try_fmt_vid_capture(struct file *file, void *fh, struct v4l2_format *f); +extern int fimc_enum_fmt_vid_capture(struct file *file, void *fh, + struct v4l2_fmtdesc *f); +extern int fimc_g_fmt_vid_capture(struct file *file, void *fh, + struct v4l2_format *f); +extern int fimc_s_fmt_vid_capture(struct file *file, void *fh, + struct v4l2_format *f); +extern int fimc_try_fmt_vid_capture(struct file *file, void *fh, + struct v4l2_format *f); extern int fimc_reqbufs_capture(void *fh, struct v4l2_requestbuffers *b); extern int fimc_querybuf_capture(void *fh, struct v4l2_buffer *b); extern int fimc_g_ctrl_capture(void *fh, struct v4l2_control *c); @@ -471,29 +488,40 @@ extern int fimc_streamon_capture(void *fh); extern int fimc_streamoff_capture(void *fh); extern int fimc_qbuf_capture(void *fh, struct v4l2_buffer *b); extern int fimc_dqbuf_capture(void *fh, struct v4l2_buffer *b); -extern int fimc_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a); -extern int fimc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a); -extern int fimc_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *qc); -extern int fimc_querymenu(struct file *file, void *fh, struct v4l2_querymenu *qm); +extern int fimc_g_parm(struct file *file, void *fh, + struct v4l2_streamparm *a); +extern int fimc_s_parm(struct file *file, void *fh, + struct v4l2_streamparm *a); +extern int fimc_queryctrl(struct file *file, void *fh, + struct v4l2_queryctrl *qc); +extern int fimc_querymenu(struct file *file, void *fh, + struct v4l2_querymenu *qm); #if defined(CONFIG_CPU_S5PV210) extern int fimc_change_clksrc(struct fimc_control *ctrl, int fimc_clk); #endif extern int fimc_release_subdev(struct fimc_control *ctrl); -void fimc_hwset_stop_processing(struct fimc_control *ctrl); /* output device */ -extern void fimc_outdev_set_src_addr(struct fimc_control *ctrl, dma_addr_t *base); -extern int fimc_outdev_set_ctx_param(struct fimc_control *ctrl, struct fimc_ctx *ctx); -extern int fimc_start_fifo(struct fimc_control *ctrl, struct fimc_ctx *ctx); -extern int fimc_fimd_rect(const struct fimc_control *ctrl, const struct fimc_ctx *ctx, struct v4l2_rect *fimd_rect); -extern int fimc_outdev_stop_streaming(struct fimc_control *ctrl, struct fimc_ctx *ctx); -extern int fimc_outdev_resume_dma(struct fimc_control *ctrl, struct fimc_ctx *ctx); +extern void fimc_outdev_set_src_addr(struct fimc_control *ctrl, + dma_addr_t *base); +extern int fimc_outdev_set_ctx_param(struct fimc_control *ctrl, + struct fimc_ctx *ctx); +extern int fimc_start_fifo(struct fimc_control *ctrl, + struct fimc_ctx *ctx); +extern int fimc_fimd_rect(const struct fimc_control *ctrl, + const struct fimc_ctx *ctx, + struct v4l2_rect *fimd_rect); +extern int fimc_outdev_stop_streaming(struct fimc_control *ctrl, + struct fimc_ctx *ctx); +extern int fimc_outdev_resume_dma(struct fimc_control *ctrl, + struct fimc_ctx *ctx); extern int fimc_outdev_start_camif(void *param); extern int fimc_reqbufs_output(void *fh, struct v4l2_requestbuffers *b); extern int fimc_querybuf_output(void *fh, struct v4l2_buffer *b); extern int fimc_g_ctrl_output(void *fh, struct v4l2_control *c); -extern int fimc_s_ctrl_output(struct file *filp, void *fh, struct v4l2_control *c); +extern int fimc_s_ctrl_output(struct file *filp, void *fh, + struct v4l2_control *c); extern int fimc_cropcap_output(void *fh, struct v4l2_cropcap *a); extern int fimc_g_crop_output(void *fh, struct v4l2_crop *a); extern int fimc_s_crop_output(void *fh, struct v4l2_crop *a); @@ -501,16 +529,22 @@ extern int fimc_streamon_output(void *fh); extern int fimc_streamoff_output(void *fh); extern int fimc_qbuf_output(void *fh, struct v4l2_buffer *b); extern int fimc_dqbuf_output(void *fh, struct v4l2_buffer *b); -extern int fimc_g_fmt_vid_out(struct file *filp, void *fh, struct v4l2_format *f); -extern int fimc_s_fmt_vid_out(struct file *filp, void *fh, struct v4l2_format *f); -extern int fimc_try_fmt_vid_out(struct file *filp, void *fh, struct v4l2_format *f); -extern int fimc_output_set_dst_addr(struct fimc_control *ctrl, struct fimc_ctx *ctx, int idx); - +extern int fimc_g_fmt_vid_out(struct file *filp, void *fh, + struct v4l2_format *f); +extern int fimc_s_fmt_vid_out(struct file *filp, void *fh, + struct v4l2_format *f); +extern int fimc_try_fmt_vid_out(struct file *filp, void *fh, + struct v4l2_format *f); +extern int fimc_output_set_dst_addr(struct fimc_control *ctrl, + struct fimc_ctx *ctx, int idx); extern int fimc_init_in_queue(struct fimc_control *ctrl, struct fimc_ctx *ctx); -extern int fimc_push_inq(struct fimc_control *ctrl, struct fimc_ctx *ctx, int idx); +extern int fimc_push_inq(struct fimc_control *ctrl, + struct fimc_ctx *ctx, int idx); extern int fimc_pop_inq(struct fimc_control *ctrl, int *ctx_num, int *idx); -extern int fimc_push_outq(struct fimc_control *ctrl, struct fimc_ctx *ctx, int idx); -extern int fimc_pop_outq(struct fimc_control *ctrl, struct fimc_ctx *ctx, int *idx); +extern int fimc_push_outq(struct fimc_control *ctrl, + struct fimc_ctx *ctx, int idx); +extern int fimc_pop_outq(struct fimc_control *ctrl, + struct fimc_ctx *ctx, int *idx); extern int fimc_init_out_queue(struct fimc_control *ctrl, struct fimc_ctx *ctx); extern void fimc_outdev_init_idxs(struct fimc_control *ctrl); @@ -518,16 +552,22 @@ extern void fimc_dump_context(struct fimc_control *ctrl, struct fimc_ctx *ctx); extern void fimc_print_signal(struct fimc_control *ctrl); /* overlay device */ -extern int fimc_try_fmt_overlay(struct file *filp, void *fh, struct v4l2_format *f); -extern int fimc_g_fmt_vid_overlay(struct file *filp, void *fh, struct v4l2_format *f); -extern int fimc_s_fmt_vid_overlay(struct file *filp, void *fh, struct v4l2_format *f); -extern int fimc_g_fbuf(struct file *filp, void *fh, struct v4l2_framebuffer *fb); -extern int fimc_s_fbuf(struct file *filp, void *fh, struct v4l2_framebuffer *fb); +extern int fimc_try_fmt_overlay(struct file *filp, void *fh, + struct v4l2_format *f); +extern int fimc_g_fmt_vid_overlay(struct file *filp, void *fh, + struct v4l2_format *f); +extern int fimc_s_fmt_vid_overlay(struct file *filp, void *fh, + struct v4l2_format *f); +extern int fimc_g_fbuf(struct file *filp, void *fh, + struct v4l2_framebuffer *fb); +extern int fimc_s_fbuf(struct file *filp, void *fh, + struct v4l2_framebuffer *fb); /* Register access file */ extern void fimc_reset(struct fimc_control *ctrl); extern int fimc_hwset_camera_source(struct fimc_control *ctrl); -extern int fimc_hwset_enable_irq(struct fimc_control *ctrl, int overflow, int level); +extern int fimc_hwset_enable_irq(struct fimc_control *ctrl, + int overflow, int level); extern int fimc_hwset_disable_irq(struct fimc_control *ctrl); extern int fimc_hwset_clear_irq(struct fimc_control *ctrl); extern int fimc_hwset_reset(struct fimc_control *ctrl); @@ -536,17 +576,25 @@ extern int fimc_hwget_overflow_state(struct fimc_control *ctrl); extern int fimc_hwset_camera_offset(struct fimc_control *ctrl); extern int fimc_hwset_camera_polarity(struct fimc_control *ctrl); extern int fimc_hwset_camera_type(struct fimc_control *ctrl); -extern int fimc_hwset_output_size(struct fimc_control *ctrl, int width, int height); -extern int fimc_hwset_output_colorspace(struct fimc_control *ctrl, u32 pixelformat); -extern int fimc_hwset_output_rot_flip(struct fimc_control *ctrl, u32 rot, u32 flip); -extern int fimc_hwset_output_area(struct fimc_control *ctrl, u32 width, u32 height); +extern int fimc_hwset_output_size(struct fimc_control *ctrl, + int width, int height); +extern int fimc_hwset_output_colorspace(struct fimc_control *ctrl, + u32 pixelformat); +extern int fimc_hwset_output_rot_flip(struct fimc_control *ctrl, + u32 rot, u32 flip); +extern int fimc_hwset_output_area(struct fimc_control *ctrl, + u32 width, u32 height); extern int fimc_hwset_output_area_size(struct fimc_control *ctrl, u32 size); -extern int fimc_hwset_output_scan(struct fimc_control *ctrl, struct v4l2_pix_format *fmt); +extern int fimc_hwset_output_scan(struct fimc_control *ctrl, + struct v4l2_pix_format *fmt); extern int fimc_hwset_enable_lastirq(struct fimc_control *ctrl); extern int fimc_hwset_disable_lastirq(struct fimc_control *ctrl); -extern int fimc_hwset_prescaler(struct fimc_control *ctrl, struct fimc_scaler *sc); +extern int fimc_hwset_prescaler(struct fimc_control *ctrl, + struct fimc_scaler *sc); extern int fimc_hwset_output_yuv(struct fimc_control *ctrl, u32 pixelformat); -extern int fimc_hwset_output_address(struct fimc_control *ctrl, struct fimc_buf_set *bs, int id); +extern int fimc_hwset_output_address(struct fimc_control *ctrl, + struct fimc_buf_set *bs, + int id); extern int fimc_hwset_input_rot(struct fimc_control *ctrl, u32 rot, u32 flip); extern int fimc_hwset_scaler(struct fimc_control *ctrl, struct fimc_scaler *sc); extern int fimc_hwset_scaler_bypass(struct fimc_control *ctrl); @@ -555,39 +603,56 @@ extern int fimc_hwset_disable_lcdfifo(struct fimc_control *ctrl); extern int fimc_hwset_start_scaler(struct fimc_control *ctrl); extern int fimc_hwset_stop_scaler(struct fimc_control *ctrl); extern int fimc_hwset_input_rgb(struct fimc_control *ctrl, u32 pixelformat); -extern int fimc_hwset_intput_field(struct fimc_control *ctrl, enum v4l2_field field); +extern int fimc_hwset_intput_field(struct fimc_control *ctrl, + enum v4l2_field field); extern int fimc_hwset_output_rgb(struct fimc_control *ctrl, u32 pixelformat); extern int fimc_hwset_ext_rgb(struct fimc_control *ctrl, int enable); -extern int fimc_hwset_enable_capture(struct fimc_control *ctrl, u32 bypass); +extern int fimc_hwset_enable_capture(struct fimc_control *ctrl, + u32 bypass); extern int fimc_hwset_disable_capture(struct fimc_control *ctrl); extern void fimc_wait_disable_capture(struct fimc_control *ctrl); -extern int fimc_hwset_input_address(struct fimc_control *ctrl, dma_addr_t *base); +extern int fimc_hwset_input_address(struct fimc_control *ctrl, + dma_addr_t *base); extern int fimc_hwset_enable_autoload(struct fimc_control *ctrl); extern int fimc_hwset_disable_autoload(struct fimc_control *ctrl); -extern int fimc_hwset_real_input_size(struct fimc_control *ctrl, u32 width, u32 height); +extern int fimc_hwset_real_input_size(struct fimc_control *ctrl, + u32 width, u32 height); extern int fimc_hwset_addr_change_enable(struct fimc_control *ctrl); extern int fimc_hwset_addr_change_disable(struct fimc_control *ctrl); extern int fimc_hwset_input_burst_cnt(struct fimc_control *ctrl, u32 cnt); -extern int fimc_hwset_input_colorspace(struct fimc_control *ctrl, u32 pixelformat); +extern int fimc_hwset_input_colorspace(struct fimc_control *ctrl, + u32 pixelformat); extern int fimc_hwset_input_yuv(struct fimc_control *ctrl, u32 pixelformat); extern int fimc_hwset_input_flip(struct fimc_control *ctrl, u32 rot, u32 flip); -extern int fimc_hwset_input_source(struct fimc_control *ctrl, enum fimc_input path); +extern int fimc_hwset_input_source(struct fimc_control *ctrl, + enum fimc_input path); extern int fimc_hwset_start_input_dma(struct fimc_control *ctrl); extern int fimc_hwset_stop_input_dma(struct fimc_control *ctrl); -extern int fimc_hwset_output_offset(struct fimc_control *ctrl, u32 pixelformat, struct v4l2_rect *bound, struct v4l2_rect *crop); -extern int fimc_hwset_input_offset(struct fimc_control *ctrl, u32 pixelformat, struct v4l2_rect *bound, struct v4l2_rect *crop); -extern int fimc_hwset_org_input_size(struct fimc_control *ctrl, u32 width, u32 height); -extern int fimc_hwset_org_output_size(struct fimc_control *ctrl, u32 width, u32 height); -extern int fimc_hwset_ext_output_size(struct fimc_control *ctrl, u32 width, u32 height); -extern int fimc_hwset_input_addr_style(struct fimc_control *ctrl, u32 pixelformat); -extern int fimc_hwset_output_addr_style(struct fimc_control *ctrl, u32 pixelformat); +extern int fimc_hwset_output_offset(struct fimc_control *ctrl, + u32 pixelformat, + struct v4l2_rect *bound, + struct v4l2_rect *crop); +extern int fimc_hwset_input_offset(struct fimc_control *ctrl, + u32 pixelformat, + struct v4l2_rect *bound, + struct v4l2_rect *crop); +extern int fimc_hwset_org_input_size(struct fimc_control *ctrl, + u32 width, u32 height); +extern int fimc_hwset_org_output_size(struct fimc_control *ctrl, + u32 width, u32 height); +extern int fimc_hwset_ext_output_size(struct fimc_control *ctrl, + u32 width, u32 height); +extern int fimc_hwset_input_addr_style(struct fimc_control *ctrl, + u32 pixelformat); +extern int fimc_hwset_output_addr_style(struct fimc_control *ctrl, + u32 pixelformat); extern int fimc_hwset_jpeg_mode(struct fimc_control *ctrl, bool enable); extern int fimc_hwget_frame_count(struct fimc_control *ctrl); extern int fimc_hw_wait_winoff(struct fimc_control *ctrl); extern int fimc_hw_wait_stop_input_dma(struct fimc_control *ctrl); extern int fimc_hwset_input_lineskip(struct fimc_control *ctrl); extern int fimc_hw_reset_camera(struct fimc_control *ctrl); -void fimc_hwset_stop_processing(struct fimc_control *ctrl); +extern void fimc_hwset_stop_processing(struct fimc_control *ctrl); extern int fimc_hwset_image_effect(struct fimc_control *ctrl); extern int fimc_hwset_shadow_enable(struct fimc_control *ctrl); extern int fimc_hwset_shadow_disable(struct fimc_control *ctrl); @@ -602,7 +667,7 @@ extern void ipc_start(void); * D R I V E R H E L P E R S * */ -#define to_fimc_plat(d) to_platform_device(d)->dev.platform_data +#define to_fimc_plat(d) (to_platform_device(d)->dev.platform_data) static inline struct fimc_global *get_fimc_dev(void) { diff --git a/drivers/media/video/samsung/fimc/fimc_capture.c b/drivers/media/video/samsung/fimc/fimc_capture.c index 466772f..b7df637 100644 --- a/drivers/media/video/samsung/fimc/fimc_capture.c +++ b/drivers/media/video/samsung/fimc/fimc_capture.c @@ -1,11 +1,9 @@ -/* linux/drivers/media/video/samsung/fimc_capture.c +/* linux/drivers/media/video/samsung/fimc/fimc_capture.c * - * V4L2 Capture device support file for Samsung Camera Interface (FIMC) driver + * Copyright (c) 2010 Samsung Electronics Co., Ltd. + * http://www.samsung.com/ * - * Dongsoo Kim, Copyright (c) 2009 Samsung Electronics - * http://www.samsung.com/sec/ - * Jinsung Yang, Copyright (c) 2009 Samsung Electronics - * http://www.samsungsemi.com/ + * V4L2 Capture device support file for Samsung Camera Interface (FIMC) driver * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -33,7 +31,7 @@ #define subdev_call(ctrl, o, f, args...) \ v4l2_subdev_call(ctrl->cam->sd, o, f, ##args) -//#define FIMC_CAP_DEBUG +/* #define FIMC_CAP_DEBUG */ #ifdef FIMC_CAP_DEBUG #ifdef fimc_dbg @@ -42,7 +40,7 @@ #define fimc_dbg fimc_err #endif -const static struct v4l2_fmtdesc capture_fmts[] = { +static const struct v4l2_fmtdesc capture_fmts[] = { { .index = 0, .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, @@ -130,7 +128,7 @@ const static struct v4l2_fmtdesc capture_fmts[] = { }, }; -const static struct v4l2_queryctrl fimc_controls[] = { +static const struct v4l2_queryctrl fimc_controls[] = { { .id = V4L2_CID_ROTATION, .type = V4L2_CTRL_TYPE_BOOLEAN, @@ -195,7 +193,8 @@ const static struct v4l2_queryctrl fimc_controls[] = { }; #ifndef CONFIG_VIDEO_FIMC_MIPI -void s3c_csis_start(int lanes, int settle, int align, int width, int height, int pixel_format) {} +void s3c_csis_start(int lanes, int settle, int align, int width, int height, + int pixel_format) {} #endif static int fimc_camera_init(struct fimc_control *ctrl) @@ -221,19 +220,19 @@ static int fimc_camera_init(struct fimc_control *ctrl) } if (ctrl->cam->type == CAM_TYPE_MIPI) { - /* - * subdev call for sleep/wakeup: + /* subdev call for sleep/wakeup: * no error although no s_stream api support - */ + */ u32 pixelformat; - if (ctrl->cap->fmt.pixelformat == V4L2_PIX_FMT_JPEG) + if (ctrl->cap->fmt.pixelformat == V4L2_PIX_FMT_JPEG) pixelformat = V4L2_PIX_FMT_JPEG; else pixelformat = ctrl->cam->pixelformat; subdev_call(ctrl, video, s_stream, 0); s3c_csis_start(ctrl->cam->mipi_lanes, ctrl->cam->mipi_settle, \ - ctrl->cam->mipi_align, ctrl->cam->width, ctrl->cam->height, pixelformat); + ctrl->cam->mipi_align, ctrl->cam->width, \ + ctrl->cam->height, pixelformat); subdev_call(ctrl, video, s_stream, 1); } @@ -243,12 +242,13 @@ static int fimc_camera_init(struct fimc_control *ctrl) } -/* This function must be called after s_fmt and s_parm call to the subdev has already been made. +/* This function must be called after s_fmt and s_parm call to the subdev + * has already been made. + * + * - obtains the camera output (input to FIMC) resolution. + * - sets the preview size (aka camera output resolution) and framerate. + * - starts the preview operation. * - * - obtains the camera output (input to FIMC) resolution. - * - sets the preview size (aka camera output resolution) and framerate. - * - starts the preview operation. - * * On success, returns 0. * On failure, returns the error code of the call that failed. */ @@ -258,10 +258,10 @@ static int fimc_camera_start(struct fimc_control *ctrl) struct v4l2_control cam_ctrl; int ret; - ret = subdev_call(ctrl, video, enum_framesizes, &cam_frmsize); - if(ret < 0){ - fimc_err("%s: enum_framesizes failed\n", __func__); - if(ret != -ENOIOCTLCMD) + ret = subdev_call(ctrl, video, enum_framesizes, &cam_frmsize); + if (ret < 0) { + fimc_err("%s: enum_framesizes failed\n", __func__); + if (ret != -ENOIOCTLCMD) return ret; } else { ctrl->cam->width = cam_frmsize.discrete.width; @@ -275,17 +275,20 @@ static int fimc_camera_start(struct fimc_control *ctrl) cam_ctrl.id = V4L2_CID_CAM_PREVIEW_ONOFF; cam_ctrl.value = 1; - ret = subdev_call(ctrl, core, s_ctrl, &cam_ctrl); + ret = subdev_call(ctrl, core, s_ctrl, &cam_ctrl); - /* When the device is waking up from sleep, this call may fail. In that case, it is - * better to reset the camera sensor and start again. If the preview fails again, the - * reason might be something else and we should return the error. */ - if(ret < 0 && ret != -ENOIOCTLCMD){ + /* When the device is waking up from sleep, this call may fail. In + * that case, it is better to reset the camera sensor and start again. + * If the preview fails again, the reason might be something else and + * we should return the error. + */ + if (ret < 0 && ret != -ENOIOCTLCMD) { ctrl->cam->initialized = 0; - fimc_camera_init(ctrl); - ret = subdev_call(ctrl, core, s_ctrl, &cam_ctrl); - if(ret < 0 && ret != -ENOIOCTLCMD){ - fimc_err("%s: Error in V4L2_CID_CAM_PREVIEW_ONOFF - start\n", __func__); + fimc_camera_init(ctrl); + ret = subdev_call(ctrl, core, s_ctrl, &cam_ctrl); + if (ret < 0 && ret != -ENOIOCTLCMD) { + fimc_err("%s: Error in V4L2_CID_CAM_PREVIEW_ONOFF" + " - start\n", __func__); return ret; } } @@ -299,9 +302,10 @@ static int fimc_camera_get_jpeg_memsize(struct fimc_control *ctrl) struct v4l2_control cam_ctrl; cam_ctrl.id = V4L2_CID_CAM_JPEG_MEMSIZE; - ret = subdev_call(ctrl, core, g_ctrl, &cam_ctrl); - if(ret < 0){ - fimc_err("%s: Subdev doesn't support JEPG encoding.\n", __func__); + ret = subdev_call(ctrl, core, g_ctrl, &cam_ctrl); + if (ret < 0) { + fimc_err("%s: Subdev doesn't support JEPG encoding.\n", \ + __func__); return 0; } @@ -323,7 +327,8 @@ static int fimc_capture_scaler_info(struct fimc_control *ctrl) sc->real_width = sx; sc->real_height = sy; - fimc_dbg("%s: CamOut (%d, %d), TargetOut (%d, %d)\n", __func__, sx, sy, tx, ty); + fimc_dbg("%s: CamOut (%d, %d), TargetOut (%d, %d)\n", \ + __func__, sx, sy, tx, ty); if (sx <= 0 || sy <= 0) { fimc_err("%s: invalid source size\n", __func__); @@ -364,12 +369,13 @@ static int fimc_add_inqueue(struct fimc_control *ctrl, int i) struct fimc_buf_set *buf; - if(i >= cap->nr_bufs) + if (i >= cap->nr_bufs) return -EINVAL; - list_for_each_entry(buf, &cap->inq, list){ - if(buf->id == i){ - fimc_dbg("%s: buffer %d already in inqueue.\n", __func__, i); + list_for_each_entry(buf, &cap->inq, list) { + if (buf->id == i) { + fimc_dbg("%s: buffer %d already in inqueue.\n", \ + __func__, i); return -EINVAL; } } @@ -403,9 +409,9 @@ static int fimc_update_hwaddr(struct fimc_control *ctrl) { int i; - for (i = 0; i < FIMC_PHYBUFS; i++){ + for (i = 0; i < FIMC_PHYBUFS; i++) fimc_add_outqueue(ctrl, i); - } + return 0; } @@ -416,7 +422,7 @@ int fimc_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a) fimc_dbg("%s\n", __func__); - if(!ctrl->cam || !ctrl->cam->sd){ + if (!ctrl->cam || !ctrl->cam->sd) { fimc_err("%s: No capture device.\n", __func__); return -ENODEV; } @@ -435,13 +441,13 @@ int fimc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a) fimc_dbg("%s\n", __func__); - if(!ctrl->cam || !ctrl->cam->sd){ + if (!ctrl->cam || !ctrl->cam->sd) { fimc_err("%s: No capture device.\n", __func__); return -ENODEV; } mutex_lock(&ctrl->v4l2_lock); - if(ctrl->id != 2) + if (ctrl->id != 2) ret = subdev_call(ctrl, video, s_parm, a); mutex_unlock(&ctrl->v4l2_lock); @@ -487,7 +493,9 @@ int fimc_querymenu(struct file *file, void *fh, struct v4l2_querymenu *qm) } -/* Given the index, we will return the camera name if there is any camera present at the given id. */ +/* Given the index, we will return the camera name if there is any camera + * present at the given id. + */ int fimc_enum_input(struct file *file, void *fh, struct v4l2_input *inp) { struct fimc_global *fimc = get_fimc_dev(); @@ -496,7 +504,8 @@ int fimc_enum_input(struct file *file, void *fh, struct v4l2_input *inp) fimc_dbg("%s: index %d\n", __func__, inp->index); if (inp->index < 0 || inp->index >= FIMC_MAXCAMS) { - fimc_err("%s: invalid input index, received = %d\n", __func__, inp->index); + fimc_err("%s: invalid input index, received = %d\n", \ + __func__, inp->index); return -EINVAL; } @@ -533,12 +542,12 @@ int fimc_release_subdev(struct fimc_control *ctrl) struct fimc_global *fimc = get_fimc_dev(); struct i2c_client *client; - if(ctrl && ctrl->cam && ctrl->cam->sd){ + if (ctrl && ctrl->cam && ctrl->cam->sd) { fimc_dbg("%s called\n", __func__); client = v4l2_get_subdevdata(ctrl->cam->sd); i2c_unregister_device(client); ctrl->cam->sd = NULL; - if(ctrl->cam->cam_power) + if (ctrl->cam->cam_power) ctrl->cam->cam_power(0); ctrl->cam->initialized = 0; ctrl->cam = NULL; @@ -556,17 +565,16 @@ static int fimc_configure_subdev(struct fimc_control *ctrl) char *name; /* set parent for mclk */ - if(clk_get_parent(ctrl->cam->clk->parent)) + if (clk_get_parent(ctrl->cam->clk->parent)) clk_set_parent(ctrl->cam->clk->parent, ctrl->cam->srclk); /* set rate for mclk */ - if (clk_get_rate(ctrl->cam->clk)) + if (clk_get_rate(ctrl->cam->clk)) clk_set_rate(ctrl->cam->clk, ctrl->cam->clk_rate); i2c_adap = i2c_get_adapter(ctrl->cam->i2c_busnum); - if (!i2c_adap) { + if (!i2c_adap) fimc_err("subdev i2c_adapter missing-skip registration\n"); - } i2c_info = ctrl->cam->info; if (!i2c_info) { @@ -620,29 +628,31 @@ int fimc_s_input(struct file *file, void *fh, unsigned int i) if (!fimc->camera_isvalid[i]) return -EINVAL; - if(fimc->camera[i].sd && ctrl->id != 2){ + if (fimc->camera[i].sd && ctrl->id != 2) { fimc_err("%s: Camera already in use.\n", __func__); return -EBUSY; } mutex_lock(&ctrl->v4l2_lock); /* If ctrl->cam is not NULL, there is one subdev already registered. - * We need to unregister that subdev first. */ - if(i != fimc->active_camera){ + * We need to unregister that subdev first. + */ + if (i != fimc->active_camera) { fimc_release_subdev(ctrl); ctrl->cam = &fimc->camera[i]; ret = fimc_configure_subdev(ctrl); - if(ret < 0){ + if (ret < 0) { mutex_unlock(&ctrl->v4l2_lock); - fimc_err("%s: Could not register camera sensor with V4L2.\n", __func__); + fimc_err("%s: Could not register camera sensor " + "with V4L2.\n", __func__); return -ENODEV; - } + } fimc->active_camera = i; } - if(ctrl->id == 2){ - if (i == fimc->active_camera){ - ctrl->cam = &fimc->camera[i]; + if (ctrl->id == 2) { + if (i == fimc->active_camera) { + ctrl->cam = &fimc->camera[i]; } else { mutex_unlock(&ctrl->v4l2_lock); return -EINVAL; @@ -664,14 +674,14 @@ int fimc_enum_fmt_vid_capture(struct file *file, void *fh, fimc_dbg("%s\n", __func__); - if(!ctrl->cam || !ctrl->cam->sd){ + if (!ctrl->cam || !ctrl->cam->sd) { fimc_err("%s: No capture device.\n", __func__); return -ENODEV; } num_entries = sizeof(capture_fmts)/sizeof(struct v4l2_fmtdesc); - if(i >= num_entries){ + if (i >= num_entries) { f->index -= num_entries; mutex_lock(&ctrl->v4l2_lock); ret = subdev_call(ctrl, video, enum_fmt, f); @@ -773,7 +783,8 @@ static int fimc_fmt_depth(struct fimc_control *ctrl, struct v4l2_format *f) fimc_dbg("Compressed format.\n"); break; default: - fimc_dbg("why am I here? - received %x\n", f->fmt.pix.pixelformat); + fimc_dbg("why am I here? - received %x\n", + f->fmt.pix.pixelformat); break; } @@ -789,7 +800,7 @@ int fimc_s_fmt_vid_capture(struct file *file, void *fh, struct v4l2_format *f) fimc_dbg("%s\n", __func__); - if(!ctrl->cam || !ctrl->cam->sd){ + if (!ctrl->cam || !ctrl->cam->sd) { fimc_err("%s: No capture device.\n", __func__); return -ENODEV; } @@ -824,18 +835,21 @@ int fimc_s_fmt_vid_capture(struct file *file, void *fh, struct v4l2_format *f) * bytesperline = width * depth / 8 * sizeimage = bytesperline * height */ - /* This function may return 0 or -1 in case of error, hence need to check here. */ + /* This function may return 0 or -1 in case of error, hence need to + * check here. + */ depth = fimc_fmt_depth(ctrl, f); - if(depth == 0){ + if (depth == 0) { mutex_unlock(&ctrl->v4l2_lock); fimc_err("%s: Invalid pixel format\n", __func__); return -EINVAL; - } else if(depth < 0){ + } else if (depth < 0) { /* - * When the pixelformat is JPEG, the application is requesting for data - * in JPEG compressed format. */ + * When the pixelformat is JPEG, the application is requesting + * for data in JPEG compressed format. + */ ret = subdev_call(ctrl, video, try_fmt, f); - if(ret < 0){ + if (ret < 0) { mutex_unlock(&ctrl->v4l2_lock); return -EINVAL; } @@ -849,8 +863,8 @@ int fimc_s_fmt_vid_capture(struct file *file, void *fh, struct v4l2_format *f) ctrl->sc.bypass = 1; cap->lastirq = 1; } - - if(ctrl->id != 2) + + if (ctrl->id != 2) ret = subdev_call(ctrl, video, s_fmt, f); mutex_unlock(&ctrl->v4l2_lock); @@ -868,14 +882,12 @@ static int fimc_alloc_buffers(struct fimc_control *ctrl, int size[], int align) struct fimc_capinfo *cap = ctrl->cap; int i, plane; - for (i = 0; i < cap->nr_bufs; i++) - { - for(plane = 0; plane < 4; plane++) - { + for (i = 0; i < cap->nr_bufs; i++) { + for (plane = 0; plane < 4; plane++) { cap->bufs[i].length[plane] = size[plane]; - if(!cap->bufs[i].length[plane]) + if (!cap->bufs[i].length[plane]) continue; - + fimc_dma_alloc(ctrl, &cap->bufs[i], plane, align); if (!cap->bufs[i].base[plane]) @@ -904,15 +916,15 @@ static void fimc_free_buffers(struct fimc_control *ctrl) struct fimc_capinfo *cap; int i; - if(ctrl && ctrl->cap) + if (ctrl && ctrl->cap) cap = ctrl->cap; else return; - for(i=0; i < FIMC_PHYBUFS; i++){ + for (i = 0; i < FIMC_PHYBUFS; i++) { memset(&cap->bufs[i], 0, sizeof(cap->bufs[i])); - cap->bufs[i].state = VIDEOBUF_NEEDS_INIT; + cap->bufs[i].state = VIDEOBUF_NEEDS_INIT; } ctrl->mem.curr = ctrl->mem.base; @@ -936,7 +948,7 @@ int fimc_reqbufs_capture(void *fh, struct v4l2_requestbuffers *b) return -ENODEV; } - if(!ctrl->cam || !ctrl->cam->sd){ + if (!ctrl->cam || !ctrl->cam->sd) { fimc_err("%s: No capture device.\n", __func__); return -ENODEV; } @@ -946,7 +958,9 @@ int fimc_reqbufs_capture(void *fh, struct v4l2_requestbuffers *b) if (b->count < 1 || b->count > FIMC_CAPBUFS) return -EINVAL; - /* It causes flickering as buf_0 and buf_3 refer to same hardware address. */ + /* It causes flickering as buf_0 and buf_3 refer to same hardware + * address. + */ if (b->count == 3) b->count = 4; @@ -967,9 +981,9 @@ int fimc_reqbufs_capture(void *fh, struct v4l2_requestbuffers *b) case V4L2_PIX_FMT_YUV422P: /* fall through */ size[0] = cap->fmt.sizeimage; break; - + case V4L2_PIX_FMT_NV16: /* fall through */ - case V4L2_PIX_FMT_NV61: + case V4L2_PIX_FMT_NV61: size[0] = cap->fmt.width * cap->fmt.height; size[1] = cap->fmt.width * cap->fmt.height; size[3] = 16; /* Padding buffer */ @@ -985,19 +999,28 @@ int fimc_reqbufs_capture(void *fh, struct v4l2_requestbuffers *b) break; case V4L2_PIX_FMT_NV12T: /* Tiled frame size calculations as per 4x2 tiles - * - Width: Has to be aligned to 2 times the tile width - * - Height: Has to be aligned to the tile height - * - Alignment: Has to be aligned to the size of the macrotile (size of 4 tiles) - * - * NOTE: In case of rotation, we need modified calculation as width and height - * are aligned to different values. - */ - if(cap->rotate == 90 || cap->rotate == 270){ - size[0] = ALIGN(ALIGN(cap->fmt.height, 128) * ALIGN(cap->fmt.width, 32), SZ_8K); - size[1] = ALIGN(ALIGN(cap->fmt.height, 128) * ALIGN(cap->fmt.width/2, 32), SZ_8K); + * - Width: Has to be aligned to 2 times the tile width + * - Height: Has to be aligned to the tile height + * - Alignment: Has to be aligned to the size of the + * macrotile (size of 4 tiles) + * + * NOTE: In case of rotation, we need modified calculation as + * width and height are aligned to different values. + */ + if (cap->rotate == 90 || cap->rotate == 270) { + size[0] = ALIGN(ALIGN(cap->fmt.height, 128) * + ALIGN(cap->fmt.width, 32), + SZ_8K); + size[1] = ALIGN(ALIGN(cap->fmt.height, 128) * + ALIGN(cap->fmt.width/2, 32), + SZ_8K); } else { - size[0] = ALIGN(ALIGN(cap->fmt.width, 128) * ALIGN(cap->fmt.height, 32), SZ_8K); - size[1] = ALIGN(ALIGN(cap->fmt.width, 128) * ALIGN(cap->fmt.height/2, 32), SZ_8K); + size[0] = ALIGN(ALIGN(cap->fmt.width, 128) * + ALIGN(cap->fmt.height, 32), + SZ_8K); + size[1] = ALIGN(ALIGN(cap->fmt.width, 128) * + ALIGN(cap->fmt.height/2, 32), + SZ_8K); } align = SZ_8K; break; @@ -1037,7 +1060,7 @@ int fimc_querybuf_capture(void *fh, struct v4l2_buffer *b) { struct fimc_control *ctrl = ((struct fimc_prv_data *)fh)->ctrl; - if(!ctrl->cap || !ctrl->cap->bufs){ + if (!ctrl->cap || !ctrl->cap->bufs) { fimc_err("%s: no capture device info\n", __func__); return -ENODEV; } @@ -1049,9 +1072,9 @@ int fimc_querybuf_capture(void *fh, struct v4l2_buffer *b) mutex_lock(&ctrl->v4l2_lock); - b->length = ctrl->cap->bufs[b->index].length[FIMC_ADDR_Y] - + ctrl->cap->bufs[b->index].length[FIMC_ADDR_CB] - + ctrl->cap->bufs[b->index].length[FIMC_ADDR_CR]; + b->length = ctrl->cap->bufs[b->index].length[FIMC_ADDR_Y] + + ctrl->cap->bufs[b->index].length[FIMC_ADDR_CB] + + ctrl->cap->bufs[b->index].length[FIMC_ADDR_CR]; b->m.offset = b->index * PAGE_SIZE; @@ -1071,7 +1094,7 @@ int fimc_g_ctrl_capture(void *fh, struct v4l2_control *c) fimc_dbg("%s\n", __func__); - if(!ctrl->cam || !ctrl->cam->sd || !ctrl->cap){ + if (!ctrl->cam || !ctrl->cam->sd || !ctrl->cap) { fimc_err("%s: No capture device.\n", __func__); return -ENODEV; } @@ -1108,9 +1131,9 @@ int fimc_g_ctrl_capture(void *fh, struct v4l2_control *c) * We used s_ctrl API to get the physical address of the buffers. * In g_ctrl, we can pass only one parameter, thus we cannot pass * the index of the buffer. - * In order to use g_ctrl for obtaining the physical address, we - * will have to create CID ids for all values (4 ids for Y0~Y3 and 4 ids - * for C0~C3). Currently, we will continue with the existing + * In order to use g_ctrl for obtaining the physical address, we + * will have to create CID ids for all values (4 ids for Y0~Y3 and 4 ids + * for C0~C3). Currently, we will continue with the existing * implementation till we get any better idea to implement. */ int fimc_s_ctrl_capture(void *fh, struct v4l2_control *c) @@ -1118,9 +1141,9 @@ int fimc_s_ctrl_capture(void *fh, struct v4l2_control *c) struct fimc_control *ctrl = ((struct fimc_prv_data *)fh)->ctrl; int ret = 0; - //fimc_dbg("%s\n", __func__); + fimc_info2("%s\n", __func__); - if(!ctrl->cam || !ctrl->cam->sd || !ctrl->cap || !ctrl->cap->bufs){ + if (!ctrl->cam || !ctrl->cam->sd || !ctrl->cap || !ctrl->cap->bufs) { fimc_err("%s: No capture device.\n", __func__); return -ENODEV; } @@ -1153,10 +1176,10 @@ int fimc_s_ctrl_capture(void *fh, struct v4l2_control *c) break; /* Implementation as per C100 FIMC driver */ - case V4L2_CID_STREAM_PAUSE: - fimc_hwset_stop_processing(ctrl); - break; - + case V4L2_CID_STREAM_PAUSE: + fimc_hwset_stop_processing(ctrl); + break; + case V4L2_CID_IMAGE_EFFECT_APPLY: ctrl->fe.ie_on = c->value ? 1 : 0; ctrl->fe.ie_after_sc = 0; @@ -1164,7 +1187,7 @@ int fimc_s_ctrl_capture(void *fh, struct v4l2_control *c) break; case V4L2_CID_IMAGE_EFFECT_FN: - if(c->value < 0 || c->value > FIMC_EFFECT_FIN_SILHOUETTE) + if (c->value < 0 || c->value > FIMC_EFFECT_FIN_SILHOUETTE) return -EINVAL; ctrl->fe.fin = c->value; ret = 0; @@ -1183,7 +1206,7 @@ int fimc_s_ctrl_capture(void *fh, struct v4l2_control *c) default: /* try on subdev */ mutex_unlock(&ctrl->v4l2_lock); - if(2 != ctrl->id) + if (2 != ctrl->id) ret = subdev_call(ctrl, core, s_ctrl, c); else ret = 0; @@ -1218,7 +1241,7 @@ int fimc_cropcap_capture(void *fh, struct v4l2_cropcap *a) fimc_dbg("%s\n", __func__); - if(!ctrl->cam || !ctrl->cam->sd || !ctrl->cap){ + if (!ctrl->cam || !ctrl->cam->sd || !ctrl->cap) { fimc_err("%s: No capture device.\n", __func__); return -ENODEV; } @@ -1251,7 +1274,7 @@ int fimc_g_crop_capture(void *fh, struct v4l2_crop *a) fimc_dbg("%s\n", __func__); - if(!ctrl->cap){ + if (!ctrl->cap) { fimc_err("%s: No capture device.\n", __func__); return -ENODEV; } @@ -1272,23 +1295,30 @@ static int fimc_capture_crop_size_check(struct fimc_control *ctrl) /* check win_hor_offset, win_hor_offset2 */ win_hor_offset = ctrl->cam->window.left; - win_hor_offset2 = ctrl->cam->width - ctrl->cam->window.left - ctrl->cam->window.width; + win_hor_offset2 = ctrl->cam->width - ctrl->cam->window.left - + ctrl->cam->window.width; win_ver_offset = ctrl->cam->window.top; - win_ver_offset2 = ctrl->cam->height - ctrl->cam->window.top - ctrl->cam->window.height; - - if (win_hor_offset < 0 || win_hor_offset2 < 0){ - fimc_err("%s: Offset (left-side(%d) or right-side(%d) is negative.\n", __func__, win_hor_offset, win_hor_offset2); + win_ver_offset2 = ctrl->cam->height - ctrl->cam->window.top - + ctrl->cam->window.height; + + if (win_hor_offset < 0 || win_hor_offset2 < 0) { + fimc_err("%s: Offset (left-side(%d) or right-side(%d) " + "is negative.\n", __func__, \ + win_hor_offset, win_hor_offset2); return -1; } - if (win_ver_offset < 0 || win_ver_offset2 < 0){ - fimc_err("%s: Offset (top-side(%d) or bottom-side(%d)) is negative.\n", __func__, win_ver_offset, win_ver_offset2); + if (win_ver_offset < 0 || win_ver_offset2 < 0) { + fimc_err("%s: Offset (top-side(%d) or bottom-side(%d)) " + "is negative.\n", __func__, \ + win_ver_offset, win_ver_offset2); return -1; } if ((win_hor_offset % 2) || (win_hor_offset2 % 2)) { - fimc_err("%s: win_hor_offset must be multiple of 2\n", __func__); + fimc_err("%s: win_hor_offset must be multiple of 2\n", \ + __func__); return -1; } @@ -1302,29 +1332,29 @@ static int fimc_capture_crop_size_check(struct fimc_control *ctrl) } switch (cap->fmt.pixelformat) { - case V4L2_PIX_FMT_YUV420: /* fall through */ - case V4L2_PIX_FMT_NV12: /* fall through */ - case V4L2_PIX_FMT_NV21: /* fall through */ - case V4L2_PIX_FMT_NV12T: /* fall through */ - if ((crop_height % 2) || (crop_height < 8)) { - fimc_err("%s: crop_height error!\n", __func__); - return -1; - } - break; - default: - break; + case V4L2_PIX_FMT_YUV420: /* fall through */ + case V4L2_PIX_FMT_NV12: /* fall through */ + case V4L2_PIX_FMT_NV21: /* fall through */ + case V4L2_PIX_FMT_NV12T: /* fall through */ + if ((crop_height % 2) || (crop_height < 8)) { + fimc_err("%s: crop_height error!\n", __func__); + return -1; + } + break; + default: + break; } return 0; } -/** Given crop parameters are w.r.t. target resolution. Scale +/** Given crop parameters are w.r.t. target resolution. Scale * it w.r.t. camera source resolution. - * - * Steps: - * 1. Scale as camera resolution with fixed-point calculation - * 2. Check for overflow condition - * 3. Apply FIMC constrainsts + * + * Steps: + * 1. Scale as camera resolution with fixed-point calculation + * 2. Check for overflow condition + * 3. Apply FIMC constrainsts */ static void fimc_capture_update_crop_window(struct fimc_control *ctrl) { @@ -1332,46 +1362,54 @@ static void fimc_capture_update_crop_window(struct fimc_control *ctrl) unsigned int zoom_ver = 0; unsigned int multiplier = 1024; - if(!ctrl->cam->width || !ctrl->cam->height) + if (!ctrl->cam->width || !ctrl->cam->height) return; zoom_hor = ctrl->cap->fmt.width * multiplier / ctrl->cam->width; zoom_ver = ctrl->cap->fmt.height * multiplier / ctrl->cam->height; - if(!zoom_hor || !zoom_ver) + if (!zoom_hor || !zoom_ver) return; /* Width */ ctrl->cam->window.width = ctrl->cap->crop.width * multiplier / zoom_hor; - if(ctrl->cam->window.width > ctrl->cam->width) + if (ctrl->cam->window.width > ctrl->cam->width) ctrl->cam->window.width = ctrl->cam->width; - if(ctrl->cam->window.width % 16) - ctrl->cam->window.width = (ctrl->cam->window.width + 0xF) & ~0xF; + if (ctrl->cam->window.width % 16) + ctrl->cam->window.width = + (ctrl->cam->window.width + 0xF) & ~0xF; /* Left offset */ ctrl->cam->window.left = ctrl->cap->crop.left * multiplier / zoom_hor; - if(ctrl->cam->window.width + ctrl->cam->window.left > ctrl->cam->width) - ctrl->cam->window.left = (ctrl->cam->width - ctrl->cam->window.width)/2; - if(ctrl->cam->window.left % 2) + if (ctrl->cam->window.width + ctrl->cam->window.left > ctrl->cam->width) + ctrl->cam->window.left = + (ctrl->cam->width - ctrl->cam->window.width)/2; + if (ctrl->cam->window.left % 2) ctrl->cam->window.left--; /* Height */ - ctrl->cam->window.height = ctrl->cap->crop.height * multiplier / zoom_ver; - if(ctrl->cam->window.top > ctrl->cam->height) + ctrl->cam->window.height = + (ctrl->cap->crop.height * multiplier) / zoom_ver; + if (ctrl->cam->window.top > ctrl->cam->height) ctrl->cam->window.height = ctrl->cam->height; - if(ctrl->cam->window.height % 2) + if (ctrl->cam->window.height % 2) ctrl->cam->window.height--; - /* Top offset */ + /* Top offset */ ctrl->cam->window.top = ctrl->cap->crop.top * multiplier / zoom_ver; - if(ctrl->cam->window.height + ctrl->cam->window.top > ctrl->cam->height) - ctrl->cam->window.top = (ctrl->cam->height - ctrl->cam->window.height)/2; - if(ctrl->cam->window.top % 2) + if (ctrl->cam->window.height + ctrl->cam->window.top > + ctrl->cam->height) + ctrl->cam->window.top = + (ctrl->cam->height - ctrl->cam->window.height)/2; + if (ctrl->cam->window.top % 2) ctrl->cam->window.top--; - fimc_dbg("Cam (%dx%d) Crop: (%d %d %d %d) Win: (%d %d %d %d)\n", ctrl->cam->width, ctrl->cam->height, \ - ctrl->cap->crop.left, ctrl->cap->crop.top, ctrl->cap->crop.width, ctrl->cap->crop.height, \ - ctrl->cam->window.left, ctrl->cam->window.top, ctrl->cam->window.width, ctrl->cam->window.height); + fimc_dbg("Cam (%dx%d) Crop: (%d %d %d %d) Win: (%d %d %d %d)\n", \ + ctrl->cam->width, ctrl->cam->height, \ + ctrl->cap->crop.left, ctrl->cap->crop.top, \ + ctrl->cap->crop.width, ctrl->cap->crop.height, \ + ctrl->cam->window.left, ctrl->cam->window.top, \ + ctrl->cam->window.width, ctrl->cam->window.height); } @@ -1382,7 +1420,7 @@ int fimc_s_crop_capture(void *fh, struct v4l2_crop *a) fimc_dbg("%s\n", __func__); - if(!ctrl->cap){ + if (!ctrl->cap) { fimc_err("%s: No capture device.\n", __func__); return -ENODEV; } @@ -1392,14 +1430,15 @@ int fimc_s_crop_capture(void *fh, struct v4l2_crop *a) fimc_capture_update_crop_window(ctrl); - ret = fimc_capture_crop_size_check(ctrl); - if(ret < 0){ + ret = fimc_capture_crop_size_check(ctrl); + if (ret < 0) { mutex_unlock(&ctrl->v4l2_lock); fimc_err("%s: Invalid crop parameters.\n", __func__); return -EINVAL; } - - if (ctrl->status == FIMC_STREAMON && ctrl->cap->fmt.pixelformat != V4L2_PIX_FMT_JPEG) { + + if (ctrl->status == FIMC_STREAMON && + ctrl->cap->fmt.pixelformat != V4L2_PIX_FMT_JPEG) { fimc_hwset_shadow_disable(ctrl); fimc_hwset_camera_offset(ctrl); fimc_capture_scaler_info(ctrl); @@ -1441,7 +1480,7 @@ int fimc_stop_capture(struct fimc_control *ctrl) fimc_hwset_disable_irq(ctrl); fimc_hwset_clear_irq(ctrl); - if(!ctrl->sc.bypass) + if (!ctrl->sc.bypass) fimc_hwset_stop_scaler(ctrl); else ctrl->sc.bypass = 0; @@ -1459,12 +1498,12 @@ static void fimc_reset_capture(struct fimc_control *ctrl) fimc_stop_capture(ctrl); - for(i = 0; i < FIMC_PHYBUFS; i++) + for (i = 0; i < FIMC_PHYBUFS; i++) fimc_add_inqueue(ctrl, ctrl->cap->outq[i]); fimc_hwset_reset(ctrl); - if(0 != ctrl->id) + if (0 != ctrl->id) fimc_clk_en(ctrl, false); ctrl->status = FIMC_STREAMOFF; @@ -1480,19 +1519,19 @@ int fimc_streamon_capture(void *fh) fimc_dbg("%s\n", __func__); - if(!ctrl->cam || !ctrl->cam->sd){ + if (!ctrl->cam || !ctrl->cam->sd) { fimc_err("%s: No capture device.\n", __func__); return -ENODEV; } - if(ctrl->status == FIMC_STREAMON){ + if (ctrl->status == FIMC_STREAMON) { fimc_err("%s: Camera already running.\n", __func__); - return -EBUSY; - } + return -EBUSY; + } mutex_lock(&ctrl->v4l2_lock); - if(0 != ctrl->id) + if (0 != ctrl->id) fimc_clk_en(ctrl, true); ctrl->status = FIMC_READY_ON; @@ -1503,9 +1542,10 @@ int fimc_streamon_capture(void *fh) if (!ctrl->cam->initialized) fimc_camera_init(ctrl); - if(ctrl->id != 2 && ctrl->cap->fmt.colorspace != V4L2_COLORSPACE_JPEG){ + if (ctrl->id != 2 && + ctrl->cap->fmt.colorspace != V4L2_COLORSPACE_JPEG) { ret = fimc_camera_start(ctrl); - if(ret < 0){ + if (ret < 0) { fimc_reset_capture(ctrl); mutex_unlock(&ctrl->v4l2_lock); return ret; @@ -1516,7 +1556,7 @@ int fimc_streamon_capture(void *fh) fimc_hwset_camera_polarity(ctrl); fimc_update_hwaddr(ctrl); - if(cap->fmt.pixelformat != V4L2_PIX_FMT_JPEG){ + if (cap->fmt.pixelformat != V4L2_PIX_FMT_JPEG) { fimc_hwset_camera_source(ctrl); fimc_hwset_camera_offset(ctrl); @@ -1533,7 +1573,7 @@ int fimc_streamon_capture(void *fh) fimc_hwset_output_rgb(ctrl, cap->fmt.pixelformat); else fimc_hwset_output_yuv(ctrl, cap->fmt.pixelformat); - + fimc_hwset_output_size(ctrl, cap->fmt.width, cap->fmt.height); fimc_hwset_output_scan(ctrl, &cap->fmt); @@ -1549,25 +1589,27 @@ int fimc_streamon_capture(void *fh) } fimc_hwset_jpeg_mode(ctrl, false); } else { - fimc_hwset_output_area_size(ctrl, fimc_camera_get_jpeg_memsize(ctrl)/2); + fimc_hwset_output_area_size(ctrl, \ + fimc_camera_get_jpeg_memsize(ctrl)/2); fimc_hwset_jpeg_mode(ctrl, true); } - if(ctrl->cap->fmt.colorspace == V4L2_COLORSPACE_JPEG){ + if (ctrl->cap->fmt.colorspace == V4L2_COLORSPACE_JPEG) fimc_hwset_scaler_bypass(ctrl); - } fimc_start_capture(ctrl); - if(ctrl->cap->fmt.colorspace == V4L2_COLORSPACE_JPEG && ctrl->id != 2){ + if (ctrl->cap->fmt.colorspace == V4L2_COLORSPACE_JPEG && + ctrl->id != 2) { struct v4l2_control cam_ctrl; cam_ctrl.id = V4L2_CID_CAM_CAPTURE; ret = subdev_call(ctrl, core, s_ctrl, &cam_ctrl); - if(ret < 0 && ret != -ENOIOCTLCMD){ + if (ret < 0 && ret != -ENOIOCTLCMD) { fimc_reset_capture(ctrl); mutex_unlock(&ctrl->v4l2_lock); - fimc_err("%s: Error in V4L2_CID_CAM_CAPTURE\n", __func__); + fimc_err("%s: Error in V4L2_CID_CAM_CAPTURE\n", \ + __func__); return -EPERM; } } @@ -1585,7 +1627,7 @@ int fimc_streamoff_capture(void *fh) fimc_dbg("%s\n", __func__); - if(!ctrl->cap || !ctrl->cam || !ctrl->cam->sd){ + if (!ctrl->cap || !ctrl->cam || !ctrl->cam->sd) { fimc_err("%s: No capture info.\n", __func__); return -ENODEV; } @@ -1621,7 +1663,7 @@ int fimc_dqbuf_capture(void *fh, struct v4l2_buffer *b) struct fimc_capinfo *cap; int pp, ret = 0; - if(!ctrl->cap || !ctrl->cap->nr_bufs){ + if (!ctrl->cap || !ctrl->cap->nr_bufs) { fimc_err("%s: Invalid capture setting.\n", __func__); return -EINVAL; } @@ -1635,7 +1677,7 @@ int fimc_dqbuf_capture(void *fh, struct v4l2_buffer *b) mutex_lock(&ctrl->v4l2_lock); - if(ctrl->status != FIMC_STREAMON){ + if (ctrl->status != FIMC_STREAMON) { mutex_unlock(&ctrl->v4l2_lock); fimc_dbg("%s: FIMC is not active.\n", __func__); return -EINVAL; @@ -1643,8 +1685,10 @@ int fimc_dqbuf_capture(void *fh, struct v4l2_buffer *b) /* find out the real index */ pp = ((fimc_hwget_frame_count(ctrl) + 2) % 4) % cap->nr_bufs; - - /* We have read the latest frame, hence should reset availability flag */ + + /* We have read the latest frame, hence should reset availability + * flag + */ cap->irq = 0; /* skip even frame: no data */ @@ -1664,7 +1708,7 @@ int fimc_dqbuf_capture(void *fh, struct v4l2_buffer *b) mutex_unlock(&ctrl->v4l2_lock); - //fimc_dbg("%s: buf_index = %d\n", __func__, b->index); + /* fimc_dbg("%s: buf_index = %d\n", __func__, b->index); */ return ret; } diff --git a/drivers/media/video/samsung/fimc/fimc_dev.c b/drivers/media/video/samsung/fimc/fimc_dev.c index 1fc29c2..7cda8b9 100644 --- a/drivers/media/video/samsung/fimc/fimc_dev.c +++ b/drivers/media/video/samsung/fimc/fimc_dev.c @@ -103,7 +103,7 @@ void fimc_dma_free(struct fimc_control *ctrl, struct fimc_buf_set *bs, int i) void fimc_clk_en(struct fimc_control *ctrl, bool on) { struct platform_device *pdev; - struct s3c_platform_fimc *pdata; + struct s3c_platform_fimc *pdata; struct clk *lclk; pdev = to_platform_device(ctrl->dev); @@ -131,7 +131,7 @@ void fimc_clk_en(struct fimc_control *ctrl, bool on) /* Turn off fimc power domain regulator */ regulator_disable(ctrl->regulator); } - } + } } @@ -274,7 +274,8 @@ static inline u32 fimc_irq_out_dma(struct fimc_control *ctrl, ret = s3cfb_direct_ioctl(ctrl->id, S3CFB_SET_WIN_ON, (unsigned long)NULL); if (ret < 0) { - fimc_err("direct_ioctl(S3CFB_SET_WIN_ON) fail\n"); + fimc_err("direct_ioctl " + "(S3CFB_SET_WIN_ON) fail\n"); return -EINVAL; } @@ -567,8 +568,8 @@ int fimc_mmap_out_src(struct file *filp, struct vm_area_struct *vma) int pri_data = 0; buf_length = PAGE_ALIGN(ctx->src[idx].length[FIMC_ADDR_Y] + - ctx->src[idx].length[FIMC_ADDR_CB] + - ctx->src[idx].length[FIMC_ADDR_CR]); + ctx->src[idx].length[FIMC_ADDR_CB] + + ctx->src[idx].length[FIMC_ADDR_CR]); if (size > PAGE_ALIGN(buf_length)) { fimc_err("Requested mmap size is too big\n"); return -EINVAL; @@ -835,8 +836,8 @@ void fimc_get_nv12t_size(int img_hres, int img_vres, cb_hres_byte = img_hres - 1; cb_vres_byte = (img_vres >> 1) - 1; - cb_hres_roundup = ((cb_hres_byte>> 4) >> 3) + 1; - cb_vres_roundup = ((cb_vres_byte>> 4) >> 2) + 1; + cb_hres_roundup = ((cb_hres_byte >> 4) >> 3) + 1; + cb_vres_roundup = ((cb_vres_byte >> 4) >> 2) + 1; if ((cb_vres_byte & 0x20) == 0) { cb_hres_byte = cb_hres_byte & 0x7f00; cb_hres_byte = cb_hres_byte >> 8; @@ -858,11 +859,11 @@ static int fimc_get_free_ctx(struct fimc_control *ctrl) { int i; - if(1 != ctrl->id) + if (1 != ctrl->id) return 0; - for(i = 0; i < FIMC_MAX_CTXS; i++){ - if(ctrl->ctx_busy[i] == 0){ + for (i = 0; i < FIMC_MAX_CTXS; i++) { + if (ctrl->ctx_busy[i] == 0) { ctrl->ctx_busy[i] = 1; fimc_info1("Current context is %d\n", i); return i; @@ -903,8 +904,8 @@ static int fimc_open(struct file *filp) } prv_data->ctx_id = fimc_get_free_ctx(ctrl); - if(prv_data->ctx_id < 0){ - fimc_err("%s: Context busy flag not reset. \n", __func__); + if (prv_data->ctx_id < 0) { + fimc_err("%s: Context busy flag not reset.\n", __func__); ret = -EBUSY; goto ctx_err; } @@ -936,7 +937,7 @@ static int fimc_open(struct file *filp) ctrl->mem.curr = ctrl->mem.base; ctrl->status = FIMC_STREAMOFF; - if(0 != ctrl->id) + if (0 != ctrl->id) fimc_clk_en(ctrl, false); } @@ -947,8 +948,7 @@ static int fimc_open(struct file *filp) return 0; ctx_err: - if(prv_data) - kfree(prv_data); + kfree(prv_data); kzalloc_err: atomic_dec(&ctrl->in_use); @@ -974,11 +974,13 @@ static int fimc_release(struct file *filp) pdata = to_fimc_plat(ctrl->dev); atomic_dec(&ctrl->in_use); - + /* FIXME: turning off actual working camera */ if (ctrl->cam && ctrl->id != 2) { - /* Unload the subdev (camera sensor) module, reset related status flags */ - fimc_release_subdev(ctrl); + /* Unload the subdev (camera sensor) module, + * reset related status flags + */ + fimc_release_subdev(ctrl); } if (ctrl->cap) { @@ -991,7 +993,7 @@ static int fimc_release(struct file *filp) fimc_dma_free(ctrl, &ctrl->cap->bufs[i], 1); fimc_dma_free(ctrl, &ctrl->cap->bufs[i], 2); } - + fimc_clk_en(ctrl, false); kfree(ctrl->cap); @@ -1045,9 +1047,11 @@ static int fimc_release(struct file *filp) buf = &ctx->overlay.buf; for (i = 0; i < FIMC_OUTBUFS; i++) { if (buf->vir_addr[i]) { - ret = do_munmap(mm, buf->vir_addr[i], buf->size[i]); + ret = do_munmap(mm, buf->vir_addr[i], + buf->size[i]); if (ret < 0) - fimc_err("%s: do_munmap fail\n", __func__); + fimc_err("%s: do_munmap fail\n", \ + __func__); } } @@ -1318,7 +1322,7 @@ static int __devinit fimc_probe(struct platform_device *pdev) /* fimc source clock */ srclk = clk_get(&pdev->dev, pdata->srclk_name); if (IS_ERR(srclk)) { - fimc_err( "%s: failed to get source clock of fimc\n", + fimc_err("%s: failed to get source clock of fimc\n", __func__); goto err_v4l2; } @@ -1377,7 +1381,7 @@ err_v4l2: err_fimc: fimc_unregister_controller(pdev); - + err_alloc: kfree(fimc_dev); return -EINVAL; @@ -1607,7 +1611,7 @@ static inline int fimc_resume_out(struct fimc_control *ctrl) ctx = &ctrl->out->ctx[i]; fimc_resume_out_ctx(ctrl, ctx); - switch(ctx->status) { + switch (ctx->status) { case FIMC_STREAMON: state |= FIMC_STREAMON; break; @@ -1626,9 +1630,9 @@ static inline int fimc_resume_out(struct fimc_control *ctrl) ctrl->status = FIMC_STREAMON; else if ((state & FIMC_STREAMON_IDLE) == FIMC_STREAMON_IDLE) ctrl->status = FIMC_STREAMON_IDLE; - else + else ctrl->status = FIMC_STREAMOFF; - + return 0; } @@ -1650,7 +1654,7 @@ int fimc_resume(struct platform_device *pdev) pdata = to_fimc_plat(ctrl->dev); if (atomic_read(&ctrl->in_use)) - fimc_clk_en(ctrl, true); + fimc_clk_en(ctrl, true); if (ctrl->out) fimc_resume_out(ctrl); diff --git a/drivers/media/video/samsung/fimc/fimc_output.c b/drivers/media/video/samsung/fimc/fimc_output.c index 426a82a..42c0123 100644 --- a/drivers/media/video/samsung/fimc/fimc_output.c +++ b/drivers/media/video/samsung/fimc/fimc_output.c @@ -29,41 +29,41 @@ static __u32 fimc_get_pixel_format_type(__u32 pixelformat) { - switch(pixelformat) - { - case V4L2_PIX_FMT_RGB32: - case V4L2_PIX_FMT_RGB565: - return FIMC_RGB; - - case V4L2_PIX_FMT_NV12: - case V4L2_PIX_FMT_NV12T: - case V4L2_PIX_FMT_NV21: - case V4L2_PIX_FMT_YUV420: - return FIMC_YUV420; - - case V4L2_PIX_FMT_YUYV: - case V4L2_PIX_FMT_UYVY: - case V4L2_PIX_FMT_YVYU: - case V4L2_PIX_FMT_VYUY: - case V4L2_PIX_FMT_NV16: - case V4L2_PIX_FMT_NV61: - case V4L2_PIX_FMT_YUV422P: - return FIMC_YUV422; + switch (pixelformat) { + case V4L2_PIX_FMT_RGB32: + case V4L2_PIX_FMT_RGB565: + return FIMC_RGB; - default: - return FIMC_YUV444; + case V4L2_PIX_FMT_NV12: + case V4L2_PIX_FMT_NV12T: + case V4L2_PIX_FMT_NV21: + case V4L2_PIX_FMT_YUV420: + return FIMC_YUV420; + + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_YVYU: + case V4L2_PIX_FMT_VYUY: + case V4L2_PIX_FMT_NV16: + case V4L2_PIX_FMT_NV61: + case V4L2_PIX_FMT_YUV422P: + return FIMC_YUV422; + + default: + return FIMC_YUV444; } } void fimc_outdev_set_src_addr(struct fimc_control *ctrl, dma_addr_t *base) { - volatile unsigned int * LCDControllerBase = NULL; + unsigned int *LCDControllerBase = NULL; + unsigned int offset = 0xa0/4 + CONFIG_FB_S3C_DEFAULT_WINDOW*2; - if ( base[FIMC_ADDR_Y] == 0 ) { - LCDControllerBase = (volatile unsigned int *)ioremap(0xf8000000,1024); + if (base[FIMC_ADDR_Y] == 0) { + LCDControllerBase = (unsigned int *)ioremap(0xf8000000, 1024); base[FIMC_ADDR_Y] = base[FIMC_ADDR_CB] - = base[FIMC_ADDR_CR] - = LCDControllerBase[0xa0/4 + CONFIG_FB_S3C_DEFAULT_WINDOW*2]; + = base[FIMC_ADDR_CR] + = LCDControllerBase[offset]; iounmap(LCDControllerBase); } fimc_hwset_addr_change_disable(ctrl); @@ -387,13 +387,14 @@ static int fimc_outdev_set_src_buf(struct fimc_control *ctrl, ctx->src[i].base[FIMC_ADDR_CR] = 0; ctx->src[i].length[FIMC_ADDR_CR] = 0; *curr += size; - } - break; + } + break; case V4L2_PIX_FMT_YUV420: for (i = 0; i < FIMC_OUTBUFS; i++) { ctx->src[i].base[FIMC_ADDR_Y] = *curr; ctx->src[i].base[FIMC_ADDR_CB] = *curr + y_size; - ctx->src[i].base[FIMC_ADDR_CR] = *curr + y_size + cb_size; + ctx->src[i].base[FIMC_ADDR_CR] = *curr + y_size + + cb_size; ctx->src[i].length[FIMC_ADDR_Y] = y_size; ctx->src[i].length[FIMC_ADDR_CB] = cb_size; ctx->src[i].length[FIMC_ADDR_CR] = cr_size; @@ -503,7 +504,7 @@ int fimc_outdev_check_param(struct fimc_control *ctrl, ret = -EINVAL; } else if ((dst.top + dst.height) > bound.height) { fimc_err("Vertical position setting is failed\n"); - fimc_err("\ttop = %d, height = %d, bound height = %d, \n", + fimc_err("\ttop = %d, height = %d, bound height = %d,\n", dst.top, dst.height, bound.height); ret = -EINVAL; } @@ -666,14 +667,16 @@ static int fimc4x_outdev_check_src_size(struct fimc_control *ctrl, if (ctx->sc.pre_hratio) { if (real->height % (ctx->sc.pre_hratio * 4)) { - fimc_err("SRC Real_H: multiple of 4*pre_hratio\n"); + fimc_err("SRC Real_H: multiple of " + "4*pre_hratio\n"); return -EINVAL; } } if (ctx->sc.pre_vratio) { if (real->width % ctx->sc.pre_vratio) { - fimc_err("SRC Real_W: multiple of pre_vratio\n"); + fimc_err("SRC Real_W: multiple of " + "pre_vratio\n"); return -EINVAL; } } @@ -954,7 +957,6 @@ static int fimc_outdev_check_dst_size(struct fimc_control *ctrl, pixel_type = fimc_get_pixel_format_type(ctx->fbuf.fmt.pixelformat); - // changed by jamie (2009.09.28) if (FIMC_YUV420 == pixel_type && real->height % 2) { fimc_err("DST Real_H: even number for YUV420 formats\n"); return -EINVAL; @@ -1216,7 +1218,7 @@ static int fimc_outdev_check_scaler(struct fimc_control *ctrl, case V4L2_PIX_FMT_YVYU: /* fall through */ case V4L2_PIX_FMT_VYUY: /* fall through */ case V4L2_PIX_FMT_NV16: /* fall through */ - case V4L2_PIX_FMT_NV61: + case V4L2_PIX_FMT_NV61: pixels = 2; break; case V4L2_PIX_FMT_YUV420: /* fall through */ @@ -1467,7 +1469,8 @@ int fimc_start_fifo(struct fimc_control *ctrl, struct fimc_ctx *ctx) /* Update WIN position */ window.x = fimd_rect.left; window.y = fimd_rect.top; - ret = s3cfb_direct_ioctl(id, S3CFB_WIN_POSITION, (unsigned long)&window); + ret = s3cfb_direct_ioctl(id, S3CFB_WIN_POSITION, + (unsigned long)&window); if (ret < 0) { fimc_err("direct_ioctl(S3CFB_WIN_POSITION) fail\n"); return -EINVAL; @@ -1672,14 +1675,15 @@ int fimc_g_ctrl_output(void *fh, struct v4l2_control *c) case V4L2_CID_RESERVED_MEM_BASE_ADDR: c->value = ctrl->mem.base; - if(2 == ctrl->id){ - /* Clearing the buffer for FIMC-2 + if (2 == ctrl->id) { + /* Clearing the buffer for FIMC-2 * This is required because the same buffer is used * for both Camcorder recording and HDMI display. */ char *fimc_mem = NULL; - fimc_mem = (char*) ioremap(ctrl->mem.base, ctrl->mem.size); - if(fimc_mem){ + fimc_mem = (char *) ioremap(ctrl->mem.base, \ + ctrl->mem.size); + if (fimc_mem) { memset(fimc_mem, 0x00, ctrl->mem.size); iounmap(fimc_mem); } @@ -1843,11 +1847,14 @@ int fimc_cropcap_output(void *fh, struct v4l2_cropcap *a) break; default: - fimc_warn("Supported format : V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_UYVY, \ + fimc_warn("Supported format : \ + V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_UYVY, \ V4L2_PIX_FMT_YVYU, V4L2_PIX_FMT_VYUY, \ - V4L2_PIX_FMT_NV12, V4L2_PIX_FMT_NV12T, V4L2_PIX_FMT_NV21, \ - V4L2_PIX_FMT_RGB32, V4L2_PIX_FMT_RGB565\n"); - fimc_warn("%s: Received pixel format = %x\n", __func__, pixelformat); + V4L2_PIX_FMT_NV12, V4L2_PIX_FMT_NV12T, \ + V4L2_PIX_FMT_NV21, V4L2_PIX_FMT_RGB32, \ + V4L2_PIX_FMT_RGB565\n"); + fimc_warn("%s: Received pixel format = %x\n", + __func__, pixelformat); return -EINVAL; } @@ -1901,7 +1908,7 @@ int fimc_s_crop_output(void *fh, struct v4l2_crop *a) struct fimc_control *ctrl = ((struct fimc_prv_data *)fh)->ctrl; int ctx_id = ((struct fimc_prv_data *)fh)->ctx_id; - fimc_info1("%s: called: left(%d), top(%d), width(%d), height(%d), \n", + fimc_info1("%s: called: left(%d), top(%d), width(%d), height(%d),\n", __func__, a->c.left, a->c.top, a->c.width, a->c.height); ctx = &ctrl->out->ctx[ctx_id]; @@ -2068,7 +2075,8 @@ int fimc_streamoff_output(void *fh) } -int fimc_output_set_dst_addr(struct fimc_control *ctrl, struct fimc_ctx *ctx, int idx) +int fimc_output_set_dst_addr(struct fimc_control *ctrl, + struct fimc_ctx *ctx, int idx) { struct fimc_buf_set buf_set; /* destination addr */ u32 format = ctx->fbuf.fmt.pixelformat; @@ -2080,49 +2088,61 @@ int fimc_output_set_dst_addr(struct fimc_control *ctrl, struct fimc_ctx *ctx, in memset(&buf_set, 0x00, sizeof(buf_set)); - if(V4L2_PIX_FMT_NV12T == format) + if (V4L2_PIX_FMT_NV12T == format) fimc_get_nv12t_size(width, height, &y_size, &c_size); switch (format) { - case V4L2_PIX_FMT_RGB32: - case V4L2_PIX_FMT_RGB565: - case V4L2_PIX_FMT_YUYV: /* fall through */ - case V4L2_PIX_FMT_UYVY: /* fall through */ - case V4L2_PIX_FMT_YVYU: /* fall through */ - case V4L2_PIX_FMT_VYUY: /* fall through */ - if(ctx->overlay.mode == FIMC_OVLY_NONE_SINGLE_BUF){ - buf_set.base[FIMC_ADDR_Y] = (dma_addr_t)ctx->fbuf.base; - } else { - buf_set.base[FIMC_ADDR_Y] = ctx->dst[idx].base[FIMC_ADDR_Y]; - } - break; - case V4L2_PIX_FMT_YUV420: - if(ctx->overlay.mode == FIMC_OVLY_NONE_SINGLE_BUF){ - buf_set.base[FIMC_ADDR_Y] = (dma_addr_t)ctx->fbuf.base; - buf_set.base[FIMC_ADDR_CB] = buf_set.base[FIMC_ADDR_Y] + y_size; - buf_set.base[FIMC_ADDR_CR] = buf_set.base[FIMC_ADDR_CB] + c_size; - } else { - buf_set.base[FIMC_ADDR_Y] = ctx->dst[idx].base[FIMC_ADDR_Y]; - buf_set.base[FIMC_ADDR_CB] = ctx->dst[idx].base[FIMC_ADDR_CB]; - buf_set.base[FIMC_ADDR_CR] = ctx->dst[idx].base[FIMC_ADDR_CR]; - } - break; - case V4L2_PIX_FMT_NV12: - case V4L2_PIX_FMT_NV21: - case V4L2_PIX_FMT_NV16: - case V4L2_PIX_FMT_NV61: - case V4L2_PIX_FMT_NV12T: - if(ctx->overlay.mode == FIMC_OVLY_NONE_SINGLE_BUF){ - buf_set.base[FIMC_ADDR_Y] = (dma_addr_t)ctx->fbuf.base; - buf_set.base[FIMC_ADDR_CB] = buf_set.base[FIMC_ADDR_Y] + y_size; - } else { - buf_set.base[FIMC_ADDR_Y] = ctx->dst[idx].base[FIMC_ADDR_Y]; - buf_set.base[FIMC_ADDR_CB] = ctx->dst[idx].base[FIMC_ADDR_CB]; - } - break; - default: - fimc_err("%s: Invalid pixelformt : %d\n", __func__, format); - return -EINVAL; + case V4L2_PIX_FMT_RGB32: + case V4L2_PIX_FMT_RGB565: + case V4L2_PIX_FMT_YUYV: /* fall through */ + case V4L2_PIX_FMT_UYVY: /* fall through */ + case V4L2_PIX_FMT_YVYU: /* fall through */ + case V4L2_PIX_FMT_VYUY: /* fall through */ + if (ctx->overlay.mode == FIMC_OVLY_NONE_SINGLE_BUF) + buf_set.base[FIMC_ADDR_Y] = + (dma_addr_t)ctx->fbuf.base; + else + buf_set.base[FIMC_ADDR_Y] = + ctx->dst[idx].base[FIMC_ADDR_Y]; + break; + case V4L2_PIX_FMT_YUV420: + if (ctx->overlay.mode == FIMC_OVLY_NONE_SINGLE_BUF) { + buf_set.base[FIMC_ADDR_Y] = + (dma_addr_t)ctx->fbuf.base; + buf_set.base[FIMC_ADDR_CB] = + buf_set.base[FIMC_ADDR_Y] + y_size; + buf_set.base[FIMC_ADDR_CR] = + buf_set.base[FIMC_ADDR_CB] + c_size; + } else { + buf_set.base[FIMC_ADDR_Y] = + ctx->dst[idx].base[FIMC_ADDR_Y]; + buf_set.base[FIMC_ADDR_CB] = + ctx->dst[idx].base[FIMC_ADDR_CB]; + buf_set.base[FIMC_ADDR_CR] = + ctx->dst[idx].base[FIMC_ADDR_CR]; + } + break; + case V4L2_PIX_FMT_NV12: + case V4L2_PIX_FMT_NV21: + case V4L2_PIX_FMT_NV16: + case V4L2_PIX_FMT_NV61: + case V4L2_PIX_FMT_NV12T: + if (ctx->overlay.mode == FIMC_OVLY_NONE_SINGLE_BUF) { + buf_set.base[FIMC_ADDR_Y] = + (dma_addr_t)ctx->fbuf.base; + buf_set.base[FIMC_ADDR_CB] = + buf_set.base[FIMC_ADDR_Y] + y_size; + } else { + buf_set.base[FIMC_ADDR_Y] = + ctx->dst[idx].base[FIMC_ADDR_Y]; + buf_set.base[FIMC_ADDR_CB] = + ctx->dst[idx].base[FIMC_ADDR_CB]; + } + break; + default: + fimc_err("%s: Invalid pixelformt : %d\n", \ + __func__, format); + return -EINVAL; } for (i = 0; i < FIMC_PHYBUFS; i++) @@ -2141,7 +2161,7 @@ static int fimc_qbuf_output_single_buf(struct fimc_control *ctrl, fimc_outdev_set_src_addr(ctrl, ctx->src[idx].base); ret = fimc_output_set_dst_addr(ctrl, ctx, idx); - if(ret < 0){ + if (ret < 0) { fimc_err("%s: Fail: fimc_output_set_dst_addr\n", __func__); return -EINVAL; } @@ -2170,7 +2190,7 @@ static int fimc_qbuf_output_multi_buf(struct fimc_control *ctrl, fimc_outdev_set_src_addr(ctrl, ctx->src[idx].base); fimc_output_set_dst_addr(ctrl, ctx, idx); - if(ret < 0){ + if (ret < 0) { fimc_err("%s: Fail: fimc_output_set_dst_addr\n", __func__); return -EINVAL; } @@ -2351,7 +2371,7 @@ static int fimc_update_in_queue_addr(struct fimc_control *ctrl, u32 idx, dma_addr_t *addr) { if (idx >= FIMC_OUTBUFS) { - fimc_err("%s: Failed \n", __func__); + fimc_err("%s: Failed\n", __func__); return -EINVAL; } @@ -2564,10 +2584,12 @@ int fimc_try_fmt_vid_out(struct file *filp, void *fh, struct v4l2_format *f) case V4L2_PIX_FMT_YUV420: break; default: - fimc_warn("Supported format : V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_UYVY, \ + fimc_warn("Supported format : \ + V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_UYVY, \ V4L2_PIX_FMT_YVYU, V4L2_PIX_FMT_VYUY, \ - V4L2_PIX_FMT_NV12, V4L2_PIX_FMT_NV12T, V4L2_PIX_FMT_NV21, \ - V4L2_PIX_FMT_RGB32, V4L2_PIX_FMT_RGB565\n"); + V4L2_PIX_FMT_NV12, V4L2_PIX_FMT_NV12T, \ + V4L2_PIX_FMT_NV21, V4L2_PIX_FMT_RGB32, \ + V4L2_PIX_FMT_RGB565\n"); fimc_warn("Changed format : V4L2_PIX_FMT_RGB32\n"); f->fmt.pix.pixelformat = V4L2_PIX_FMT_RGB32; return -EINVAL; diff --git a/drivers/media/video/samsung/fimc/fimc_regs.c b/drivers/media/video/samsung/fimc/fimc_regs.c index de4776b..b360f1a 100644 --- a/drivers/media/video/samsung/fimc/fimc_regs.c +++ b/drivers/media/video/samsung/fimc/fimc_regs.c @@ -172,20 +172,21 @@ void fimc_wait_disable_capture(struct fimc_control *ctrl) unsigned long timeo = jiffies + 20; /* timeout of 100 ms */ u32 cfg; - if(!ctrl || !ctrl->cap || ctrl->cap->fmt.colorspace == V4L2_COLORSPACE_JPEG) + if (!ctrl || !ctrl->cap || + ctrl->cap->fmt.colorspace == V4L2_COLORSPACE_JPEG) return; while (time_before(jiffies, timeo)) { cfg = readl(ctrl->regs + S3C_CISTATUS); - if ( 0 == (cfg & S3C_CISTATUS_IMGCPTEN) ) { + if (0 == (cfg & S3C_CISTATUS_IMGCPTEN)) break; - } msleep(10); } - dev_dbg(ctrl->dev, "IMGCPTEN: Wait time = %d ms\n", jiffies_to_msecs(jiffies - timeo + 20)); + dev_dbg(ctrl->dev, "IMGCPTEN: Wait time = %d ms\n", + jiffies_to_msecs(jiffies - timeo + 20)); return; } @@ -194,26 +195,26 @@ int fimc_hwset_image_effect(struct fimc_control *ctrl) { u32 cfg = 0; - if(ctrl->fe.ie_on){ - if(ctrl->fe.ie_after_sc) + if (ctrl->fe.ie_on) { + if (ctrl->fe.ie_after_sc) cfg |= S3C_CIIMGEFF_IE_SC_AFTER; cfg |= S3C_CIIMGEFF_FIN(ctrl->fe.fin); - if(ctrl->fe.fin == FIMC_EFFECT_FIN_ARBITRARY_CBCR){ - cfg |= S3C_CIIMGEFF_PAT_CB(ctrl->fe.pat_cb) | S3C_CIIMGEFF_PAT_CR(ctrl->fe.pat_cr); - } + if (ctrl->fe.fin == FIMC_EFFECT_FIN_ARBITRARY_CBCR) + cfg |= S3C_CIIMGEFF_PAT_CB(ctrl->fe.pat_cb) | + S3C_CIIMGEFF_PAT_CR(ctrl->fe.pat_cr); cfg |= S3C_CIIMGEFF_IE_ENABLE; - } + } writel(cfg, ctrl->regs + S3C_CIIMGEFF); - return 0; + return 0; } int fimc_hwset_shadow_enable(struct fimc_control *ctrl) -{ +{ u32 cfg = readl(ctrl->regs + S3C_CIGCTRL); cfg &= ~S3C_CIGCTRL_SHADOW_DISABLE; @@ -221,7 +222,7 @@ int fimc_hwset_shadow_enable(struct fimc_control *ctrl) writel(cfg, ctrl->regs + S3C_CIGCTRL); return 0; -} +} int fimc_hwset_shadow_disable(struct fimc_control *ctrl) { @@ -229,7 +230,7 @@ int fimc_hwset_shadow_disable(struct fimc_control *ctrl) cfg |= S3C_CIGCTRL_SHADOW_DISABLE; - writel(cfg, ctrl->regs + S3C_CIGCTRL); + writel(cfg, ctrl->regs + S3C_CIGCTRL); return 0; } @@ -456,9 +457,11 @@ int fimc43_hwset_camera_type(struct fimc_control *ctrl) /* FIXME: Temporary MIPI CSIS Data 32 bit aligned */ if (ctrl->cap->fmt.pixelformat == V4L2_PIX_FMT_JPEG) - writel((MIPI_USER_DEF_PACKET_1 | (0x1 << 8)), ctrl->regs + S3C_CSIIMGFMT); + writel((MIPI_USER_DEF_PACKET_1 | (0x1 << 8)), + ctrl->regs + S3C_CSIIMGFMT); else - writel(cam->fmt | (0x1 << 8), ctrl->regs + S3C_CSIIMGFMT); + writel(cam->fmt | (0x1 << 8), + ctrl->regs + S3C_CSIIMGFMT); } else if (cam->type == CAM_TYPE_ITU) { if (cam->id == CAMERA_PAR_A) cfg |= S3C_CIGCTRL_SELCAM_ITU_A; @@ -502,9 +505,9 @@ int fimc_hwset_jpeg_mode(struct fimc_control *ctrl, bool enable) u32 cfg; cfg = readl(ctrl->regs + S3C_CIGCTRL); - if(enable) + if (enable) cfg |= S3C_CIGCTRL_CAM_JPEG; - else + else cfg &= ~S3C_CIGCTRL_CAM_JPEG; writel(cfg, ctrl->regs + S3C_CIGCTRL); @@ -1191,15 +1194,15 @@ int fimc_hwset_input_colorspace(struct fimc_control *ctrl, u32 pixelformat) cfg |= S3C_MSCTRL_INFORMAT_YCBCR420; break; case V4L2_PIX_FMT_YUYV: /* fall through */ - case V4L2_PIX_FMT_UYVY: /* fall through */ + case V4L2_PIX_FMT_UYVY: /* fall through */ case V4L2_PIX_FMT_YVYU: /* fall through */ case V4L2_PIX_FMT_VYUY: cfg |= S3C_MSCTRL_INFORMAT_YCBCR422_1PLANE; - break; + break; case V4L2_PIX_FMT_NV16: /* fall through */ case V4L2_PIX_FMT_NV61: cfg |= S3C_MSCTRL_INFORMAT_YCBCR422; - break; + break; case V4L2_PIX_FMT_RGB565: /* fall through */ case V4L2_PIX_FMT_RGB32: cfg |= S3C_MSCTRL_INFORMAT_RGB; @@ -1228,13 +1231,13 @@ int fimc_hwset_input_yuv(struct fimc_control *ctrl, u32 pixelformat) case V4L2_PIX_FMT_YUYV: /* fall through */ cfg |= S3C_MSCTRL_ORDER422_YCBYCR; break; - case V4L2_PIX_FMT_UYVY: + case V4L2_PIX_FMT_UYVY: cfg |= S3C_MSCTRL_ORDER422_CBYCRY; break; case V4L2_PIX_FMT_YVYU: cfg |= S3C_MSCTRL_ORDER422_YCRYCB; break; - case V4L2_PIX_FMT_VYUY: + case V4L2_PIX_FMT_VYUY: cfg |= S3C_MSCTRL_ORDER422_CRYCBY; break; case V4L2_PIX_FMT_NV12: /* fall through */ @@ -1242,15 +1245,15 @@ int fimc_hwset_input_yuv(struct fimc_control *ctrl, u32 pixelformat) cfg |= S3C_MSCTRL_ORDER2P_LSB_CBCR; cfg |= S3C_MSCTRL_C_INT_IN_2PLANE; break; - case V4L2_PIX_FMT_NV21: + case V4L2_PIX_FMT_NV21: cfg |= S3C_MSCTRL_ORDER2P_LSB_CRCB; cfg |= S3C_MSCTRL_C_INT_IN_2PLANE; break; - case V4L2_PIX_FMT_NV16: + case V4L2_PIX_FMT_NV16: cfg |= S3C_MSCTRL_ORDER2P_LSB_CBCR; cfg |= S3C_MSCTRL_C_INT_IN_2PLANE; break; - case V4L2_PIX_FMT_NV61: + case V4L2_PIX_FMT_NV61: cfg |= S3C_MSCTRL_ORDER2P_LSB_CRCB; cfg |= S3C_MSCTRL_C_INT_IN_2PLANE; break; @@ -1585,7 +1588,7 @@ int fimc50_hwset_input_offset(struct fimc_control *ctrl, u32 pixelformat, cfg_cb |= S3C_CIICBOFF_VERTICAL(crop->top); break; case V4L2_PIX_FMT_NV16: /* fall through */ - case V4L2_PIX_FMT_NV61: + case V4L2_PIX_FMT_NV61: cfg_y |= S3C_CIIYOFF_HORIZONTAL(crop->left); cfg_y |= S3C_CIIYOFF_VERTICAL(crop->top); cfg_cb |= S3C_CIICBOFF_HORIZONTAL(crop->left); diff --git a/drivers/media/video/samsung/fimc/ipc_table.h b/drivers/media/video/samsung/fimc/ipc_table.h index d0e8969..0abb7f7 100644 --- a/drivers/media/video/samsung/fimc/ipc_table.h +++ b/drivers/media/video/samsung/fimc/ipc_table.h @@ -144,7 +144,7 @@ const s8 ipc_4tap_coef_c_h[] = { 0, 111, 19, -2, 3, 113, 13, -1, - /* IPC_PP_H_1_2 */ + /* IPC_PP_H_1_2 */ 0, 26, 76, 26, 0, 30, 76, 22, 0, 34, 75, 19, @@ -162,7 +162,7 @@ const s8 ipc_4tap_coef_c_h[] = { 19, 75, 34, 0, 22, 76, 30, 0, - /* IPC_PP_H_1_3 */ + /* IPC_PP_H_1_3 */ 0, 30, 68, 30, 2, 33, 66, 27, 3, 36, 66, 23, @@ -180,7 +180,7 @@ const s8 ipc_4tap_coef_c_h[] = { 23, 66, 36, 3, 27, 66, 33, 2, - /* IPC_PP_H_1_4 */ + /* IPC_PP_H_1_4 */ 0, 31, 66, 31, 3, 34, 63, 28, 4, 37, 62, 25, |