[media] s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c
authorJacek Anaszewski <j.anaszewski@samsung.com>
Wed, 18 Dec 2013 12:32:50 +0000 (09:32 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 18 Dec 2013 13:40:03 +0000 (11:40 -0200)
Move function definitions from jpeg-hw.h to jpeg-hw-s5p.c,
add "s5p" prefix and put function declarations in the jpeg-hw-s5p.h.

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/platform/s5p-jpeg/Makefile
drivers/media/platform/s5p-jpeg/jpeg-core.c
drivers/media/platform/s5p-jpeg/jpeg-core.h
drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.c [new file with mode: 0644]
drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h [new file with mode: 0644]
drivers/media/platform/s5p-jpeg/jpeg-hw.h [deleted file]

index d18cb5edd2d53975cea549bd4c696d618fb88c55..faf6398d4693e1c1a31934acd38732b9889dc89b 100644 (file)
@@ -1,2 +1,2 @@
-s5p-jpeg-objs := jpeg-core.o
+s5p-jpeg-objs := jpeg-core.o jpeg-hw-s5p.o
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg.o
index 447022f7d9ff38f7303697936385fd8b71bcdd99..65922d9126bbc205e231e9b54b1608bca7ddac61 100644 (file)
@@ -29,7 +29,7 @@
 #include <media/videobuf2-dma-contig.h>
 
 #include "jpeg-core.h"
-#include "jpeg-hw.h"
+#include "jpeg-hw-s5p.h"
 
 static struct s5p_jpeg_fmt formats_enc[] = {
        {
@@ -951,34 +951,36 @@ static void s5p_jpeg_device_run(void *priv)
        src_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0);
        dst_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
 
-       jpeg_reset(jpeg->regs);
-       jpeg_poweron(jpeg->regs);
-       jpeg_proc_mode(jpeg->regs, ctx->mode);
+       s5p_jpeg_reset(jpeg->regs);
+       s5p_jpeg_poweron(jpeg->regs);
+       s5p_jpeg_proc_mode(jpeg->regs, ctx->mode);
        if (ctx->mode == S5P_JPEG_ENCODE) {
                if (ctx->out_q.fmt->fourcc == V4L2_PIX_FMT_RGB565)
-                       jpeg_input_raw_mode(jpeg->regs, S5P_JPEG_RAW_IN_565);
+                       s5p_jpeg_input_raw_mode(jpeg->regs,
+                                                       S5P_JPEG_RAW_IN_565);
                else
-                       jpeg_input_raw_mode(jpeg->regs, S5P_JPEG_RAW_IN_422);
-               jpeg_subsampling_mode(jpeg->regs, ctx->subsampling);
-               jpeg_dri(jpeg->regs, ctx->restart_interval);
-               jpeg_x(jpeg->regs, ctx->out_q.w);
-               jpeg_y(jpeg->regs, ctx->out_q.h);
-               jpeg_imgadr(jpeg->regs, src_addr);
-               jpeg_jpgadr(jpeg->regs, dst_addr);
+                       s5p_jpeg_input_raw_mode(jpeg->regs,
+                                                       S5P_JPEG_RAW_IN_422);
+               s5p_jpeg_subsampling_mode(jpeg->regs, ctx->subsampling);
+               s5p_jpeg_dri(jpeg->regs, ctx->restart_interval);
+               s5p_jpeg_x(jpeg->regs, ctx->out_q.w);
+               s5p_jpeg_y(jpeg->regs, ctx->out_q.h);
+               s5p_jpeg_imgadr(jpeg->regs, src_addr);
+               s5p_jpeg_jpgadr(jpeg->regs, dst_addr);
 
                /* ultimately comes from sizeimage from userspace */
-               jpeg_enc_stream_int(jpeg->regs, ctx->cap_q.size);
+               s5p_jpeg_enc_stream_int(jpeg->regs, ctx->cap_q.size);
 
                /* JPEG RGB to YCbCr conversion matrix */
-               jpeg_coef(jpeg->regs, 1, 1, S5P_JPEG_COEF11);
-               jpeg_coef(jpeg->regs, 1, 2, S5P_JPEG_COEF12);
-               jpeg_coef(jpeg->regs, 1, 3, S5P_JPEG_COEF13);
-               jpeg_coef(jpeg->regs, 2, 1, S5P_JPEG_COEF21);
-               jpeg_coef(jpeg->regs, 2, 2, S5P_JPEG_COEF22);
-               jpeg_coef(jpeg->regs, 2, 3, S5P_JPEG_COEF23);
-               jpeg_coef(jpeg->regs, 3, 1, S5P_JPEG_COEF31);
-               jpeg_coef(jpeg->regs, 3, 2, S5P_JPEG_COEF32);
-               jpeg_coef(jpeg->regs, 3, 3, S5P_JPEG_COEF33);
+               s5p_jpeg_coef(jpeg->regs, 1, 1, S5P_JPEG_COEF11);
+               s5p_jpeg_coef(jpeg->regs, 1, 2, S5P_JPEG_COEF12);
+               s5p_jpeg_coef(jpeg->regs, 1, 3, S5P_JPEG_COEF13);
+               s5p_jpeg_coef(jpeg->regs, 2, 1, S5P_JPEG_COEF21);
+               s5p_jpeg_coef(jpeg->regs, 2, 2, S5P_JPEG_COEF22);
+               s5p_jpeg_coef(jpeg->regs, 2, 3, S5P_JPEG_COEF23);
+               s5p_jpeg_coef(jpeg->regs, 3, 1, S5P_JPEG_COEF31);
+               s5p_jpeg_coef(jpeg->regs, 3, 2, S5P_JPEG_COEF32);
+               s5p_jpeg_coef(jpeg->regs, 3, 3, S5P_JPEG_COEF33);
 
                /*
                 * JPEG IP allows storing 4 quantization tables
@@ -987,31 +989,31 @@ static void s5p_jpeg_device_run(void *priv)
                s5p_jpeg_set_qtbl_lum(jpeg->regs, ctx->compr_quality);
                s5p_jpeg_set_qtbl_chr(jpeg->regs, ctx->compr_quality);
                /* use table 0 for Y */
-               jpeg_qtbl(jpeg->regs, 1, 0);
+               s5p_jpeg_qtbl(jpeg->regs, 1, 0);
                /* use table 1 for Cb and Cr*/
-               jpeg_qtbl(jpeg->regs, 2, 1);
-               jpeg_qtbl(jpeg->regs, 3, 1);
+               s5p_jpeg_qtbl(jpeg->regs, 2, 1);
+               s5p_jpeg_qtbl(jpeg->regs, 3, 1);
 
                /* Y, Cb, Cr use Huffman table 0 */
-               jpeg_htbl_ac(jpeg->regs, 1);
-               jpeg_htbl_dc(jpeg->regs, 1);
-               jpeg_htbl_ac(jpeg->regs, 2);
-               jpeg_htbl_dc(jpeg->regs, 2);
-               jpeg_htbl_ac(jpeg->regs, 3);
-               jpeg_htbl_dc(jpeg->regs, 3);
+               s5p_jpeg_htbl_ac(jpeg->regs, 1);
+               s5p_jpeg_htbl_dc(jpeg->regs, 1);
+               s5p_jpeg_htbl_ac(jpeg->regs, 2);
+               s5p_jpeg_htbl_dc(jpeg->regs, 2);
+               s5p_jpeg_htbl_ac(jpeg->regs, 3);
+               s5p_jpeg_htbl_dc(jpeg->regs, 3);
        } else { /* S5P_JPEG_DECODE */
-               jpeg_rst_int_enable(jpeg->regs, true);
-               jpeg_data_num_int_enable(jpeg->regs, true);
-               jpeg_final_mcu_num_int_enable(jpeg->regs, true);
+               s5p_jpeg_rst_int_enable(jpeg->regs, true);
+               s5p_jpeg_data_num_int_enable(jpeg->regs, true);
+               s5p_jpeg_final_mcu_num_int_enable(jpeg->regs, true);
                if (ctx->cap_q.fmt->fourcc == V4L2_PIX_FMT_YUYV)
-                       jpeg_outform_raw(jpeg->regs, S5P_JPEG_RAW_OUT_422);
+                       s5p_jpeg_outform_raw(jpeg->regs, S5P_JPEG_RAW_OUT_422);
                else
-                       jpeg_outform_raw(jpeg->regs, S5P_JPEG_RAW_OUT_420);
-               jpeg_jpgadr(jpeg->regs, src_addr);
-               jpeg_imgadr(jpeg->regs, dst_addr);
+                       s5p_jpeg_outform_raw(jpeg->regs, S5P_JPEG_RAW_OUT_420);
+               s5p_jpeg_jpgadr(jpeg->regs, src_addr);
+               s5p_jpeg_imgadr(jpeg->regs, dst_addr);
        }
 
-       jpeg_start(jpeg->regs);
+       s5p_jpeg_start(jpeg->regs);
 
        spin_unlock_irqrestore(&ctx->jpeg->slock, flags);
 }
@@ -1203,22 +1205,23 @@ static irqreturn_t s5p_jpeg_irq(int irq, void *dev_id)
        dst_buf = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx);
 
        if (curr_ctx->mode == S5P_JPEG_ENCODE)
-               enc_jpeg_too_large = jpeg_enc_stream_stat(jpeg->regs);
-       timer_elapsed = jpeg_timer_stat(jpeg->regs);
-       op_completed = jpeg_result_stat_ok(jpeg->regs);
+               enc_jpeg_too_large = s5p_jpeg_enc_stream_stat(jpeg->regs);
+       timer_elapsed = s5p_jpeg_timer_stat(jpeg->regs);
+       op_completed = s5p_jpeg_result_stat_ok(jpeg->regs);
        if (curr_ctx->mode == S5P_JPEG_DECODE)
-               op_completed = op_completed && jpeg_stream_stat_ok(jpeg->regs);
+               op_completed = op_completed &&
+                                       s5p_jpeg_stream_stat_ok(jpeg->regs);
 
        if (enc_jpeg_too_large) {
                state = VB2_BUF_STATE_ERROR;
-               jpeg_clear_enc_stream_stat(jpeg->regs);
+               s5p_jpeg_clear_enc_stream_stat(jpeg->regs);
        } else if (timer_elapsed) {
                state = VB2_BUF_STATE_ERROR;
-               jpeg_clear_timer_stat(jpeg->regs);
+               s5p_jpeg_clear_timer_stat(jpeg->regs);
        } else if (!op_completed) {
                state = VB2_BUF_STATE_ERROR;
        } else {
-               payload_size = jpeg_compressed_size(jpeg->regs);
+               payload_size = s5p_jpeg_compressed_size(jpeg->regs);
        }
 
        dst_buf->v4l2_buf.timecode = src_buf->v4l2_buf.timecode;
@@ -1230,10 +1233,10 @@ static irqreturn_t s5p_jpeg_irq(int irq, void *dev_id)
        v4l2_m2m_buf_done(dst_buf, state);
        v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx);
 
-       curr_ctx->subsampling = jpeg_get_subsampling_mode(jpeg->regs);
+       curr_ctx->subsampling = s5p_jpeg_get_subsampling_mode(jpeg->regs);
        spin_unlock(&jpeg->slock);
 
-       jpeg_clear_int(jpeg->regs);
+       s5p_jpeg_clear_int(jpeg->regs);
 
        return IRQ_HANDLED;
 }
index 4a4776b7e1d42e3404b793245248d4f3cd9a1ace..7baadf395e90d256ede43ffe1545c18665d708a0 100644 (file)
 #define EOI                            0xd9
 #define DHP                            0xde
 
+#define S5P_JPEG_ENCODE                0
+#define S5P_JPEG_DECODE                1
+
 /* Flags that indicate a format can be used for capture/output */
 #define MEM2MEM_CAPTURE                        (1 << 0)
 #define MEM2MEM_OUTPUT                 (1 << 1)
 
+
+
 /**
  * struct s5p_jpeg - JPEG IP abstraction
  * @lock:              the mutex protecting this structure
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.c b/drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.c
new file mode 100644 (file)
index 0000000..52407d7
--- /dev/null
@@ -0,0 +1,343 @@
+/* linux/drivers/media/platform/s5p-jpeg/jpeg-hw.h
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ *             http://www.samsung.com
+ *
+ * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
+ *
+ * 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
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/io.h>
+#include <linux/videodev2.h>
+
+#include "jpeg-core.h"
+#include "jpeg-regs.h"
+#include "jpeg-hw-s5p.h"
+
+void s5p_jpeg_reset(void __iomem *regs)
+{
+       unsigned long reg;
+
+       writel(1, regs + S5P_JPG_SW_RESET);
+       reg = readl(regs + S5P_JPG_SW_RESET);
+       /* no other way but polling for when JPEG IP becomes operational */
+       while (reg != 0) {
+               cpu_relax();
+               reg = readl(regs + S5P_JPG_SW_RESET);
+       }
+}
+
+void s5p_jpeg_poweron(void __iomem *regs)
+{
+       writel(S5P_POWER_ON, regs + S5P_JPGCLKCON);
+}
+
+void s5p_jpeg_input_raw_mode(void __iomem *regs, unsigned long mode)
+{
+       unsigned long reg, m;
+
+       m = S5P_MOD_SEL_565;
+       if (mode == S5P_JPEG_RAW_IN_565)
+               m = S5P_MOD_SEL_565;
+       else if (mode == S5P_JPEG_RAW_IN_422)
+               m = S5P_MOD_SEL_422;
+
+       reg = readl(regs + S5P_JPGCMOD);
+       reg &= ~S5P_MOD_SEL_MASK;
+       reg |= m;
+       writel(reg, regs + S5P_JPGCMOD);
+}
+
+void s5p_jpeg_input_raw_y16(void __iomem *regs, bool y16)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPGCMOD);
+       if (y16)
+               reg |= S5P_MODE_Y16;
+       else
+               reg &= ~S5P_MODE_Y16_MASK;
+       writel(reg, regs + S5P_JPGCMOD);
+}
+
+void s5p_jpeg_proc_mode(void __iomem *regs, unsigned long mode)
+{
+       unsigned long reg, m;
+
+       m = S5P_PROC_MODE_DECOMPR;
+       if (mode == S5P_JPEG_ENCODE)
+               m = S5P_PROC_MODE_COMPR;
+       else
+               m = S5P_PROC_MODE_DECOMPR;
+       reg = readl(regs + S5P_JPGMOD);
+       reg &= ~S5P_PROC_MODE_MASK;
+       reg |= m;
+       writel(reg, regs + S5P_JPGMOD);
+}
+
+void s5p_jpeg_subsampling_mode(void __iomem *regs, unsigned int mode)
+{
+       unsigned long reg, m;
+
+       if (mode == V4L2_JPEG_CHROMA_SUBSAMPLING_420)
+               m = S5P_SUBSAMPLING_MODE_420;
+       else
+               m = S5P_SUBSAMPLING_MODE_422;
+
+       reg = readl(regs + S5P_JPGMOD);
+       reg &= ~S5P_SUBSAMPLING_MODE_MASK;
+       reg |= m;
+       writel(reg, regs + S5P_JPGMOD);
+}
+
+unsigned int s5p_jpeg_get_subsampling_mode(void __iomem *regs)
+{
+       return readl(regs + S5P_JPGMOD) & S5P_SUBSAMPLING_MODE_MASK;
+}
+
+void s5p_jpeg_dri(void __iomem *regs, unsigned int dri)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPGDRI_U);
+       reg &= ~0xff;
+       reg |= (dri >> 8) & 0xff;
+       writel(reg, regs + S5P_JPGDRI_U);
+
+       reg = readl(regs + S5P_JPGDRI_L);
+       reg &= ~0xff;
+       reg |= dri & 0xff;
+       writel(reg, regs + S5P_JPGDRI_L);
+}
+
+void s5p_jpeg_qtbl(void __iomem *regs, unsigned int t, unsigned int n)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPG_QTBL);
+       reg &= ~S5P_QT_NUMt_MASK(t);
+       reg |= (n << S5P_QT_NUMt_SHIFT(t)) & S5P_QT_NUMt_MASK(t);
+       writel(reg, regs + S5P_JPG_QTBL);
+}
+
+void s5p_jpeg_htbl_ac(void __iomem *regs, unsigned int t)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPG_HTBL);
+       reg &= ~S5P_HT_NUMt_AC_MASK(t);
+       /* this driver uses table 0 for all color components */
+       reg |= (0 << S5P_HT_NUMt_AC_SHIFT(t)) & S5P_HT_NUMt_AC_MASK(t);
+       writel(reg, regs + S5P_JPG_HTBL);
+}
+
+void s5p_jpeg_htbl_dc(void __iomem *regs, unsigned int t)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPG_HTBL);
+       reg &= ~S5P_HT_NUMt_DC_MASK(t);
+       /* this driver uses table 0 for all color components */
+       reg |= (0 << S5P_HT_NUMt_DC_SHIFT(t)) & S5P_HT_NUMt_DC_MASK(t);
+       writel(reg, regs + S5P_JPG_HTBL);
+}
+
+void s5p_jpeg_y(void __iomem *regs, unsigned int y)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPGY_U);
+       reg &= ~0xff;
+       reg |= (y >> 8) & 0xff;
+       writel(reg, regs + S5P_JPGY_U);
+
+       reg = readl(regs + S5P_JPGY_L);
+       reg &= ~0xff;
+       reg |= y & 0xff;
+       writel(reg, regs + S5P_JPGY_L);
+}
+
+void s5p_jpeg_x(void __iomem *regs, unsigned int x)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPGX_U);
+       reg &= ~0xff;
+       reg |= (x >> 8) & 0xff;
+       writel(reg, regs + S5P_JPGX_U);
+
+       reg = readl(regs + S5P_JPGX_L);
+       reg &= ~0xff;
+       reg |= x & 0xff;
+       writel(reg, regs + S5P_JPGX_L);
+}
+
+void s5p_jpeg_rst_int_enable(void __iomem *regs, bool enable)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPGINTSE);
+       reg &= ~S5P_RSTm_INT_EN_MASK;
+       if (enable)
+               reg |= S5P_RSTm_INT_EN;
+       writel(reg, regs + S5P_JPGINTSE);
+}
+
+void s5p_jpeg_data_num_int_enable(void __iomem *regs, bool enable)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPGINTSE);
+       reg &= ~S5P_DATA_NUM_INT_EN_MASK;
+       if (enable)
+               reg |= S5P_DATA_NUM_INT_EN;
+       writel(reg, regs + S5P_JPGINTSE);
+}
+
+void s5p_jpeg_final_mcu_num_int_enable(void __iomem *regs, bool enbl)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPGINTSE);
+       reg &= ~S5P_FINAL_MCU_NUM_INT_EN_MASK;
+       if (enbl)
+               reg |= S5P_FINAL_MCU_NUM_INT_EN;
+       writel(reg, regs + S5P_JPGINTSE);
+}
+
+void s5p_jpeg_timer_enable(void __iomem *regs, unsigned long val)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPG_TIMER_SE);
+       reg |= S5P_TIMER_INT_EN;
+       reg &= ~S5P_TIMER_INIT_MASK;
+       reg |= val & S5P_TIMER_INIT_MASK;
+       writel(reg, regs + S5P_JPG_TIMER_SE);
+}
+
+void s5p_jpeg_timer_disable(void __iomem *regs)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPG_TIMER_SE);
+       reg &= ~S5P_TIMER_INT_EN_MASK;
+       writel(reg, regs + S5P_JPG_TIMER_SE);
+}
+
+int s5p_jpeg_timer_stat(void __iomem *regs)
+{
+       return (int)((readl(regs + S5P_JPG_TIMER_ST) & S5P_TIMER_INT_STAT_MASK)
+                    >> S5P_TIMER_INT_STAT_SHIFT);
+}
+
+void s5p_jpeg_clear_timer_stat(void __iomem *regs)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPG_TIMER_SE);
+       reg &= ~S5P_TIMER_INT_STAT_MASK;
+       writel(reg, regs + S5P_JPG_TIMER_SE);
+}
+
+void s5p_jpeg_enc_stream_int(void __iomem *regs, unsigned long size)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPG_ENC_STREAM_INTSE);
+       reg &= ~S5P_ENC_STREAM_BOUND_MASK;
+       reg |= S5P_ENC_STREAM_INT_EN;
+       reg |= size & S5P_ENC_STREAM_BOUND_MASK;
+       writel(reg, regs + S5P_JPG_ENC_STREAM_INTSE);
+}
+
+int s5p_jpeg_enc_stream_stat(void __iomem *regs)
+{
+       return (int)(readl(regs + S5P_JPG_ENC_STREAM_INTST) &
+                    S5P_ENC_STREAM_INT_STAT_MASK);
+}
+
+void s5p_jpeg_clear_enc_stream_stat(void __iomem *regs)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPG_ENC_STREAM_INTSE);
+       reg &= ~S5P_ENC_STREAM_INT_MASK;
+       writel(reg, regs + S5P_JPG_ENC_STREAM_INTSE);
+}
+
+void s5p_jpeg_outform_raw(void __iomem *regs, unsigned long format)
+{
+       unsigned long reg, f;
+
+       f = S5P_DEC_OUT_FORMAT_422;
+       if (format == S5P_JPEG_RAW_OUT_422)
+               f = S5P_DEC_OUT_FORMAT_422;
+       else if (format == S5P_JPEG_RAW_OUT_420)
+               f = S5P_DEC_OUT_FORMAT_420;
+       reg = readl(regs + S5P_JPG_OUTFORM);
+       reg &= ~S5P_DEC_OUT_FORMAT_MASK;
+       reg |= f;
+       writel(reg, regs + S5P_JPG_OUTFORM);
+}
+
+void s5p_jpeg_jpgadr(void __iomem *regs, unsigned long addr)
+{
+       writel(addr, regs + S5P_JPG_JPGADR);
+}
+
+void s5p_jpeg_imgadr(void __iomem *regs, unsigned long addr)
+{
+       writel(addr, regs + S5P_JPG_IMGADR);
+}
+
+void s5p_jpeg_coef(void __iomem *regs, unsigned int i,
+                            unsigned int j, unsigned int coef)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPG_COEF(i));
+       reg &= ~S5P_COEFn_MASK(j);
+       reg |= (coef << S5P_COEFn_SHIFT(j)) & S5P_COEFn_MASK(j);
+       writel(reg, regs + S5P_JPG_COEF(i));
+}
+
+void s5p_jpeg_start(void __iomem *regs)
+{
+       writel(1, regs + S5P_JSTART);
+}
+
+int s5p_jpeg_result_stat_ok(void __iomem *regs)
+{
+       return (int)((readl(regs + S5P_JPGINTST) & S5P_RESULT_STAT_MASK)
+                    >> S5P_RESULT_STAT_SHIFT);
+}
+
+int s5p_jpeg_stream_stat_ok(void __iomem *regs)
+{
+       return !(int)((readl(regs + S5P_JPGINTST) & S5P_STREAM_STAT_MASK)
+                     >> S5P_STREAM_STAT_SHIFT);
+}
+
+void s5p_jpeg_clear_int(void __iomem *regs)
+{
+       unsigned long reg;
+
+       reg = readl(regs + S5P_JPGINTST);
+       writel(S5P_INT_RELEASE, regs + S5P_JPGCOM);
+       reg = readl(regs + S5P_JPGOPR);
+}
+
+unsigned int s5p_jpeg_compressed_size(void __iomem *regs)
+{
+       unsigned long jpeg_size = 0;
+
+       jpeg_size |= (readl(regs + S5P_JPGCNT_U) & 0xff) << 16;
+       jpeg_size |= (readl(regs + S5P_JPGCNT_M) & 0xff) << 8;
+       jpeg_size |= (readl(regs + S5P_JPGCNT_L) & 0xff);
+
+       return (unsigned int)jpeg_size;
+}
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h b/drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h
new file mode 100644 (file)
index 0000000..c11ebe8
--- /dev/null
@@ -0,0 +1,63 @@
+/* linux/drivers/media/platform/s5p-jpeg/jpeg-hw.h
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ *             http://www.samsung.com
+ *
+ * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
+ *
+ * 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
+ * published by the Free Software Foundation.
+ */
+#ifndef JPEG_HW_S5P_H_
+#define JPEG_HW_S5P_H_
+
+#include <linux/io.h>
+#include <linux/videodev2.h>
+
+#include "jpeg-regs.h"
+
+#define S5P_JPEG_MIN_WIDTH             32
+#define S5P_JPEG_MIN_HEIGHT            32
+#define S5P_JPEG_MAX_WIDTH             8192
+#define S5P_JPEG_MAX_HEIGHT            8192
+#define S5P_JPEG_RAW_IN_565            0
+#define S5P_JPEG_RAW_IN_422            1
+#define S5P_JPEG_RAW_OUT_422           0
+#define S5P_JPEG_RAW_OUT_420           1
+
+void s5p_jpeg_reset(void __iomem *regs);
+void s5p_jpeg_poweron(void __iomem *regs);
+void s5p_jpeg_input_raw_mode(void __iomem *regs, unsigned long mode);
+void s5p_jpeg_input_raw_y16(void __iomem *regs, bool y16);
+void s5p_jpeg_proc_mode(void __iomem *regs, unsigned long mode);
+void s5p_jpeg_subsampling_mode(void __iomem *regs, unsigned int mode);
+unsigned int s5p_jpeg_get_subsampling_mode(void __iomem *regs);
+void s5p_jpeg_dri(void __iomem *regs, unsigned int dri);
+void s5p_jpeg_qtbl(void __iomem *regs, unsigned int t, unsigned int n);
+void s5p_jpeg_htbl_ac(void __iomem *regs, unsigned int t);
+void s5p_jpeg_htbl_dc(void __iomem *regs, unsigned int t);
+void s5p_jpeg_y(void __iomem *regs, unsigned int y);
+void s5p_jpeg_x(void __iomem *regs, unsigned int x);
+void s5p_jpeg_rst_int_enable(void __iomem *regs, bool enable);
+void s5p_jpeg_data_num_int_enable(void __iomem *regs, bool enable);
+void s5p_jpeg_final_mcu_num_int_enable(void __iomem *regs, bool enbl);
+void s5p_jpeg_timer_enable(void __iomem *regs, unsigned long val);
+void s5p_jpeg_timer_disable(void __iomem *regs);
+int s5p_jpeg_timer_stat(void __iomem *regs);
+void s5p_jpeg_clear_timer_stat(void __iomem *regs);
+void s5p_jpeg_enc_stream_int(void __iomem *regs, unsigned long size);
+int s5p_jpeg_enc_stream_stat(void __iomem *regs);
+void s5p_jpeg_clear_enc_stream_stat(void __iomem *regs);
+void s5p_jpeg_outform_raw(void __iomem *regs, unsigned long format);
+void s5p_jpeg_jpgadr(void __iomem *regs, unsigned long addr);
+void s5p_jpeg_imgadr(void __iomem *regs, unsigned long addr);
+void s5p_jpeg_coef(void __iomem *regs, unsigned int i,
+                            unsigned int j, unsigned int coef);
+void s5p_jpeg_start(void __iomem *regs);
+int s5p_jpeg_result_stat_ok(void __iomem *regs);
+int s5p_jpeg_stream_stat_ok(void __iomem *regs);
+void s5p_jpeg_clear_int(void __iomem *regs);
+unsigned int s5p_jpeg_compressed_size(void __iomem *regs);
+
+#endif /* JPEG_HW_S5P_H_ */
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-hw.h b/drivers/media/platform/s5p-jpeg/jpeg-hw.h
deleted file mode 100644 (file)
index b47e887..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-/* linux/drivers/media/platform/s5p-jpeg/jpeg-hw.h
- *
- * Copyright (c) 2011 Samsung Electronics Co., Ltd.
- *             http://www.samsung.com
- *
- * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
- *
- * 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
- * published by the Free Software Foundation.
- */
-#ifndef JPEG_HW_H_
-#define JPEG_HW_H_
-
-#include <linux/io.h>
-#include <linux/videodev2.h>
-
-#include "jpeg-hw.h"
-#include "jpeg-regs.h"
-
-#define S5P_JPEG_MIN_WIDTH             32
-#define S5P_JPEG_MIN_HEIGHT            32
-#define S5P_JPEG_MAX_WIDTH             8192
-#define S5P_JPEG_MAX_HEIGHT            8192
-#define S5P_JPEG_ENCODE                        0
-#define S5P_JPEG_DECODE                        1
-#define S5P_JPEG_RAW_IN_565            0
-#define S5P_JPEG_RAW_IN_422            1
-#define S5P_JPEG_RAW_OUT_422           0
-#define S5P_JPEG_RAW_OUT_420           1
-
-static inline void jpeg_reset(void __iomem *regs)
-{
-       unsigned long reg;
-
-       writel(1, regs + S5P_JPG_SW_RESET);
-       reg = readl(regs + S5P_JPG_SW_RESET);
-       /* no other way but polling for when JPEG IP becomes operational */
-       while (reg != 0) {
-               cpu_relax();
-               reg = readl(regs + S5P_JPG_SW_RESET);
-       }
-}
-
-static inline void jpeg_poweron(void __iomem *regs)
-{
-       writel(S5P_POWER_ON, regs + S5P_JPGCLKCON);
-}
-
-static inline void jpeg_input_raw_mode(void __iomem *regs, unsigned long mode)
-{
-       unsigned long reg, m;
-
-       m = S5P_MOD_SEL_565;
-       if (mode == S5P_JPEG_RAW_IN_565)
-               m = S5P_MOD_SEL_565;
-       else if (mode == S5P_JPEG_RAW_IN_422)
-               m = S5P_MOD_SEL_422;
-
-       reg = readl(regs + S5P_JPGCMOD);
-       reg &= ~S5P_MOD_SEL_MASK;
-       reg |= m;
-       writel(reg, regs + S5P_JPGCMOD);
-}
-
-static inline void jpeg_input_raw_y16(void __iomem *regs, bool y16)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPGCMOD);
-       if (y16)
-               reg |= S5P_MODE_Y16;
-       else
-               reg &= ~S5P_MODE_Y16_MASK;
-       writel(reg, regs + S5P_JPGCMOD);
-}
-
-static inline void jpeg_proc_mode(void __iomem *regs, unsigned long mode)
-{
-       unsigned long reg, m;
-
-       m = S5P_PROC_MODE_DECOMPR;
-       if (mode == S5P_JPEG_ENCODE)
-               m = S5P_PROC_MODE_COMPR;
-       else
-               m = S5P_PROC_MODE_DECOMPR;
-       reg = readl(regs + S5P_JPGMOD);
-       reg &= ~S5P_PROC_MODE_MASK;
-       reg |= m;
-       writel(reg, regs + S5P_JPGMOD);
-}
-
-static inline void jpeg_subsampling_mode(void __iomem *regs, unsigned int mode)
-{
-       unsigned long reg, m;
-
-       if (mode == V4L2_JPEG_CHROMA_SUBSAMPLING_420)
-               m = S5P_SUBSAMPLING_MODE_420;
-       else
-               m = S5P_SUBSAMPLING_MODE_422;
-
-       reg = readl(regs + S5P_JPGMOD);
-       reg &= ~S5P_SUBSAMPLING_MODE_MASK;
-       reg |= m;
-       writel(reg, regs + S5P_JPGMOD);
-}
-
-static inline unsigned int jpeg_get_subsampling_mode(void __iomem *regs)
-{
-       return readl(regs + S5P_JPGMOD) & S5P_SUBSAMPLING_MODE_MASK;
-}
-
-static inline void jpeg_dri(void __iomem *regs, unsigned int dri)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPGDRI_U);
-       reg &= ~0xff;
-       reg |= (dri >> 8) & 0xff;
-       writel(reg, regs + S5P_JPGDRI_U);
-
-       reg = readl(regs + S5P_JPGDRI_L);
-       reg &= ~0xff;
-       reg |= dri & 0xff;
-       writel(reg, regs + S5P_JPGDRI_L);
-}
-
-static inline void jpeg_qtbl(void __iomem *regs, unsigned int t, unsigned int n)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPG_QTBL);
-       reg &= ~S5P_QT_NUMt_MASK(t);
-       reg |= (n << S5P_QT_NUMt_SHIFT(t)) & S5P_QT_NUMt_MASK(t);
-       writel(reg, regs + S5P_JPG_QTBL);
-}
-
-static inline void jpeg_htbl_ac(void __iomem *regs, unsigned int t)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPG_HTBL);
-       reg &= ~S5P_HT_NUMt_AC_MASK(t);
-       /* this driver uses table 0 for all color components */
-       reg |= (0 << S5P_HT_NUMt_AC_SHIFT(t)) & S5P_HT_NUMt_AC_MASK(t);
-       writel(reg, regs + S5P_JPG_HTBL);
-}
-
-static inline void jpeg_htbl_dc(void __iomem *regs, unsigned int t)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPG_HTBL);
-       reg &= ~S5P_HT_NUMt_DC_MASK(t);
-       /* this driver uses table 0 for all color components */
-       reg |= (0 << S5P_HT_NUMt_DC_SHIFT(t)) & S5P_HT_NUMt_DC_MASK(t);
-       writel(reg, regs + S5P_JPG_HTBL);
-}
-
-static inline void jpeg_y(void __iomem *regs, unsigned int y)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPGY_U);
-       reg &= ~0xff;
-       reg |= (y >> 8) & 0xff;
-       writel(reg, regs + S5P_JPGY_U);
-
-       reg = readl(regs + S5P_JPGY_L);
-       reg &= ~0xff;
-       reg |= y & 0xff;
-       writel(reg, regs + S5P_JPGY_L);
-}
-
-static inline void jpeg_x(void __iomem *regs, unsigned int x)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPGX_U);
-       reg &= ~0xff;
-       reg |= (x >> 8) & 0xff;
-       writel(reg, regs + S5P_JPGX_U);
-
-       reg = readl(regs + S5P_JPGX_L);
-       reg &= ~0xff;
-       reg |= x & 0xff;
-       writel(reg, regs + S5P_JPGX_L);
-}
-
-static inline void jpeg_rst_int_enable(void __iomem *regs, bool enable)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPGINTSE);
-       reg &= ~S5P_RSTm_INT_EN_MASK;
-       if (enable)
-               reg |= S5P_RSTm_INT_EN;
-       writel(reg, regs + S5P_JPGINTSE);
-}
-
-static inline void jpeg_data_num_int_enable(void __iomem *regs, bool enable)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPGINTSE);
-       reg &= ~S5P_DATA_NUM_INT_EN_MASK;
-       if (enable)
-               reg |= S5P_DATA_NUM_INT_EN;
-       writel(reg, regs + S5P_JPGINTSE);
-}
-
-static inline void jpeg_final_mcu_num_int_enable(void __iomem *regs, bool enbl)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPGINTSE);
-       reg &= ~S5P_FINAL_MCU_NUM_INT_EN_MASK;
-       if (enbl)
-               reg |= S5P_FINAL_MCU_NUM_INT_EN;
-       writel(reg, regs + S5P_JPGINTSE);
-}
-
-static inline void jpeg_timer_enable(void __iomem *regs, unsigned long val)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPG_TIMER_SE);
-       reg |= S5P_TIMER_INT_EN;
-       reg &= ~S5P_TIMER_INIT_MASK;
-       reg |= val & S5P_TIMER_INIT_MASK;
-       writel(reg, regs + S5P_JPG_TIMER_SE);
-}
-
-static inline void jpeg_timer_disable(void __iomem *regs)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPG_TIMER_SE);
-       reg &= ~S5P_TIMER_INT_EN_MASK;
-       writel(reg, regs + S5P_JPG_TIMER_SE);
-}
-
-static inline int jpeg_timer_stat(void __iomem *regs)
-{
-       return (int)((readl(regs + S5P_JPG_TIMER_ST) & S5P_TIMER_INT_STAT_MASK)
-                    >> S5P_TIMER_INT_STAT_SHIFT);
-}
-
-static inline void jpeg_clear_timer_stat(void __iomem *regs)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPG_TIMER_SE);
-       reg &= ~S5P_TIMER_INT_STAT_MASK;
-       writel(reg, regs + S5P_JPG_TIMER_SE);
-}
-
-static inline void jpeg_enc_stream_int(void __iomem *regs, unsigned long size)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPG_ENC_STREAM_INTSE);
-       reg &= ~S5P_ENC_STREAM_BOUND_MASK;
-       reg |= S5P_ENC_STREAM_INT_EN;
-       reg |= size & S5P_ENC_STREAM_BOUND_MASK;
-       writel(reg, regs + S5P_JPG_ENC_STREAM_INTSE);
-}
-
-static inline int jpeg_enc_stream_stat(void __iomem *regs)
-{
-       return (int)(readl(regs + S5P_JPG_ENC_STREAM_INTST) &
-                    S5P_ENC_STREAM_INT_STAT_MASK);
-}
-
-static inline void jpeg_clear_enc_stream_stat(void __iomem *regs)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPG_ENC_STREAM_INTSE);
-       reg &= ~S5P_ENC_STREAM_INT_MASK;
-       writel(reg, regs + S5P_JPG_ENC_STREAM_INTSE);
-}
-
-static inline void jpeg_outform_raw(void __iomem *regs, unsigned long format)
-{
-       unsigned long reg, f;
-
-       f = S5P_DEC_OUT_FORMAT_422;
-       if (format == S5P_JPEG_RAW_OUT_422)
-               f = S5P_DEC_OUT_FORMAT_422;
-       else if (format == S5P_JPEG_RAW_OUT_420)
-               f = S5P_DEC_OUT_FORMAT_420;
-       reg = readl(regs + S5P_JPG_OUTFORM);
-       reg &= ~S5P_DEC_OUT_FORMAT_MASK;
-       reg |= f;
-       writel(reg, regs + S5P_JPG_OUTFORM);
-}
-
-static inline void jpeg_jpgadr(void __iomem *regs, unsigned long addr)
-{
-       writel(addr, regs + S5P_JPG_JPGADR);
-}
-
-static inline void jpeg_imgadr(void __iomem *regs, unsigned long addr)
-{
-       writel(addr, regs + S5P_JPG_IMGADR);
-}
-
-static inline void jpeg_coef(void __iomem *regs, unsigned int i,
-                            unsigned int j, unsigned int coef)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPG_COEF(i));
-       reg &= ~S5P_COEFn_MASK(j);
-       reg |= (coef << S5P_COEFn_SHIFT(j)) & S5P_COEFn_MASK(j);
-       writel(reg, regs + S5P_JPG_COEF(i));
-}
-
-static inline void jpeg_start(void __iomem *regs)
-{
-       writel(1, regs + S5P_JSTART);
-}
-
-static inline int jpeg_result_stat_ok(void __iomem *regs)
-{
-       return (int)((readl(regs + S5P_JPGINTST) & S5P_RESULT_STAT_MASK)
-                    >> S5P_RESULT_STAT_SHIFT);
-}
-
-static inline int jpeg_stream_stat_ok(void __iomem *regs)
-{
-       return !(int)((readl(regs + S5P_JPGINTST) & S5P_STREAM_STAT_MASK)
-                     >> S5P_STREAM_STAT_SHIFT);
-}
-
-static inline void jpeg_clear_int(void __iomem *regs)
-{
-       unsigned long reg;
-
-       reg = readl(regs + S5P_JPGINTST);
-       writel(S5P_INT_RELEASE, regs + S5P_JPGCOM);
-       reg = readl(regs + S5P_JPGOPR);
-}
-
-static inline unsigned int jpeg_compressed_size(void __iomem *regs)
-{
-       unsigned long jpeg_size = 0;
-
-       jpeg_size |= (readl(regs + S5P_JPGCNT_U) & 0xff) << 16;
-       jpeg_size |= (readl(regs + S5P_JPGCNT_M) & 0xff) << 8;
-       jpeg_size |= (readl(regs + S5P_JPGCNT_L) & 0xff);
-
-       return (unsigned int)jpeg_size;
-}
-
-#endif /* JPEG_HW_H_ */