mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-02 17:16:39 +07:00
[media] Exynos4 JPEG codec v4l2 driver
Add driver for the JPEG codec IP block available in Samsung Exynos SoC series. The driver is implemented as a V4L2 mem-to-mem device. It exposes two video nodes to user space, one for the encoding part, and one for the decoding part. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Sakari Ailus <sakari.ailus@iki.fi> Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Reviewed-by: Tomasz Stanislawski <t.stanislaws@samsung.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
aa73ab96be
commit
bb677f3ac4
@ -1160,6 +1160,14 @@ config VIDEO_SAMSUNG_S5P_G2D
|
||||
This is a v4l2 driver for Samsung S5P and EXYNOS4 G2D
|
||||
2d graphics accelerator.
|
||||
|
||||
config VIDEO_SAMSUNG_S5P_JPEG
|
||||
tristate "Samsung S5P/Exynos4 JPEG codec driver (EXPERIMENTAL)"
|
||||
depends on VIDEO_DEV && VIDEO_V4L2 && PLAT_S5P && EXPERIMENTAL
|
||||
select VIDEOBUF2_DMA_CONTIG
|
||||
select V4L2_MEM2MEM_DEV
|
||||
---help---
|
||||
This is a v4l2 driver for Samsung S5P and EXYNOS4 JPEG codec
|
||||
|
||||
config VIDEO_SAMSUNG_S5P_MFC
|
||||
tristate "Samsung S5P MFC 5.1 Video Codec"
|
||||
depends on VIDEO_DEV && VIDEO_V4L2 && PLAT_S5P
|
||||
|
@ -178,6 +178,7 @@ obj-$(CONFIG_VIDEO_OMAP1) += omap1_camera.o
|
||||
obj-$(CONFIG_VIDEO_ATMEL_ISI) += atmel-isi.o
|
||||
|
||||
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC) += s5p-fimc/
|
||||
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg/
|
||||
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) += s5p-mfc/
|
||||
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV) += s5p-tv/
|
||||
|
||||
|
2
drivers/media/video/s5p-jpeg/Makefile
Normal file
2
drivers/media/video/s5p-jpeg/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
s5p-jpeg-objs := jpeg-core.o
|
||||
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) := s5p-jpeg.o
|
1481
drivers/media/video/s5p-jpeg/jpeg-core.c
Normal file
1481
drivers/media/video/s5p-jpeg/jpeg-core.c
Normal file
File diff suppressed because it is too large
Load Diff
143
drivers/media/video/s5p-jpeg/jpeg-core.h
Normal file
143
drivers/media/video/s5p-jpeg/jpeg-core.h
Normal file
@ -0,0 +1,143 @@
|
||||
/* linux/drivers/media/video/s5p-jpeg/jpeg-core.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_CORE_H_
|
||||
#define JPEG_CORE_H_
|
||||
|
||||
#include <media/v4l2-device.h>
|
||||
|
||||
#define S5P_JPEG_M2M_NAME "s5p-jpeg"
|
||||
|
||||
/* JPEG compression quality setting */
|
||||
#define S5P_JPEG_COMPR_QUAL_BEST 0
|
||||
#define S5P_JPEG_COMPR_QUAL_WORST 3
|
||||
|
||||
/* JPEG RGB to YCbCr conversion matrix coefficients */
|
||||
#define S5P_JPEG_COEF11 0x4d
|
||||
#define S5P_JPEG_COEF12 0x97
|
||||
#define S5P_JPEG_COEF13 0x1e
|
||||
#define S5P_JPEG_COEF21 0x2c
|
||||
#define S5P_JPEG_COEF22 0x57
|
||||
#define S5P_JPEG_COEF23 0x83
|
||||
#define S5P_JPEG_COEF31 0x83
|
||||
#define S5P_JPEG_COEF32 0x6e
|
||||
#define S5P_JPEG_COEF33 0x13
|
||||
|
||||
/* a selection of JPEG markers */
|
||||
#define TEM 0x01
|
||||
#define SOF0 0xc0
|
||||
#define RST 0xd0
|
||||
#define SOI 0xd8
|
||||
#define EOI 0xd9
|
||||
#define DHP 0xde
|
||||
|
||||
/* 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
|
||||
* @v4l2_dev: v4l2 device for mem2mem mode
|
||||
* @vfd_encoder: video device node for encoder mem2mem mode
|
||||
* @vfd_decoder: video device node for decoder mem2mem mode
|
||||
* @m2m_dev: v4l2 mem2mem device data
|
||||
* @ioarea: JPEG IP memory region
|
||||
* @regs: JPEG IP registers mapping
|
||||
* @irq: JPEG IP irq
|
||||
* @clk: JPEG IP clock
|
||||
* @dev: JPEG IP struct device
|
||||
* @alloc_ctx: videobuf2 memory allocator's context
|
||||
*/
|
||||
struct s5p_jpeg {
|
||||
struct mutex lock;
|
||||
|
||||
struct v4l2_device v4l2_dev;
|
||||
struct video_device *vfd_encoder;
|
||||
struct video_device *vfd_decoder;
|
||||
struct v4l2_m2m_dev *m2m_dev;
|
||||
|
||||
struct resource *ioarea;
|
||||
void __iomem *regs;
|
||||
unsigned int irq;
|
||||
struct clk *clk;
|
||||
struct device *dev;
|
||||
void *alloc_ctx;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct jpeg_fmt - driver's internal color format data
|
||||
* @name: format descritpion
|
||||
* @fourcc: the fourcc code, 0 if not applicable
|
||||
* @depth: number of bits per pixel
|
||||
* @colplanes: number of color planes (1 for packed formats)
|
||||
* @h_align: horizontal alignment order (align to 2^h_align)
|
||||
* @v_align: vertical alignment order (align to 2^v_align)
|
||||
* @types: types of queue this format is applicable to
|
||||
*/
|
||||
struct s5p_jpeg_fmt {
|
||||
char *name;
|
||||
u32 fourcc;
|
||||
int depth;
|
||||
int colplanes;
|
||||
int h_align;
|
||||
int v_align;
|
||||
u32 types;
|
||||
};
|
||||
|
||||
/**
|
||||
* s5p_jpeg_q_data - parameters of one queue
|
||||
* @fmt: driver-specific format of this queue
|
||||
* @w: image width
|
||||
* @h: image height
|
||||
* @size: image buffer size in bytes
|
||||
*/
|
||||
struct s5p_jpeg_q_data {
|
||||
struct s5p_jpeg_fmt *fmt;
|
||||
u32 w;
|
||||
u32 h;
|
||||
u32 size;
|
||||
};
|
||||
|
||||
/**
|
||||
* s5p_jpeg_ctx - the device context data
|
||||
* @jpeg: JPEG IP device for this context
|
||||
* @mode: compression (encode) operation or decompression (decode)
|
||||
* @compr_quality: destination image quality in compression (encode) mode
|
||||
* @m2m_ctx: mem2mem device context
|
||||
* @out_q: source (output) queue information
|
||||
* @cap_fmt: destination (capture) queue queue information
|
||||
* @hdr_parsed: set if header has been parsed during decompression
|
||||
*/
|
||||
struct s5p_jpeg_ctx {
|
||||
struct s5p_jpeg *jpeg;
|
||||
unsigned int mode;
|
||||
unsigned int compr_quality;
|
||||
struct v4l2_m2m_ctx *m2m_ctx;
|
||||
struct s5p_jpeg_q_data out_q;
|
||||
struct s5p_jpeg_q_data cap_q;
|
||||
bool hdr_parsed;
|
||||
};
|
||||
|
||||
/**
|
||||
* s5p_jpeg_buffer - description of memory containing input JPEG data
|
||||
* @size: buffer size
|
||||
* @curr: current position in the buffer
|
||||
* @data: pointer to the data
|
||||
*/
|
||||
struct s5p_jpeg_buffer {
|
||||
unsigned long size;
|
||||
unsigned long curr;
|
||||
unsigned long data;
|
||||
};
|
||||
|
||||
#endif /* JPEG_CORE_H */
|
353
drivers/media/video/s5p-jpeg/jpeg-hw.h
Normal file
353
drivers/media/video/s5p-jpeg/jpeg-hw.h
Normal file
@ -0,0 +1,353 @@
|
||||
/* linux/drivers/media/video/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 "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_SUBSAMPLING_422 0
|
||||
#define S5P_JPEG_SUBSAMPLING_420 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 long mode)
|
||||
{
|
||||
unsigned long reg, m;
|
||||
|
||||
m = S5P_SUBSAMPLING_MODE_422;
|
||||
if (mode == S5P_JPEG_SUBSAMPLING_422)
|
||||
m = S5P_SUBSAMPLING_MODE_422;
|
||||
else if (mode == S5P_JPEG_SUBSAMPLING_420)
|
||||
m = S5P_SUBSAMPLING_MODE_420;
|
||||
reg = readl(regs + S5P_JPGMOD);
|
||||
reg &= ~S5P_SUBSAMPLING_MODE_MASK;
|
||||
reg |= m;
|
||||
writel(reg, regs + S5P_JPGMOD);
|
||||
}
|
||||
|
||||
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_ */
|
170
drivers/media/video/s5p-jpeg/jpeg-regs.h
Normal file
170
drivers/media/video/s5p-jpeg/jpeg-regs.h
Normal file
@ -0,0 +1,170 @@
|
||||
/* linux/drivers/media/video/s5p-jpeg/jpeg-regs.h
|
||||
*
|
||||
* Register definition file for Samsung JPEG codec driver
|
||||
*
|
||||
* 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_REGS_H_
|
||||
#define JPEG_REGS_H_
|
||||
|
||||
/* JPEG mode register */
|
||||
#define S5P_JPGMOD 0x00
|
||||
#define S5P_PROC_MODE_MASK (0x1 << 3)
|
||||
#define S5P_PROC_MODE_DECOMPR (0x1 << 3)
|
||||
#define S5P_PROC_MODE_COMPR (0x0 << 3)
|
||||
#define S5P_SUBSAMPLING_MODE_MASK 0x7
|
||||
#define S5P_SUBSAMPLING_MODE_444 (0x0 << 0)
|
||||
#define S5P_SUBSAMPLING_MODE_422 (0x1 << 0)
|
||||
#define S5P_SUBSAMPLING_MODE_420 (0x2 << 0)
|
||||
#define S5P_SUBSAMPLING_MODE_GRAY (0x3 << 0)
|
||||
|
||||
/* JPEG operation status register */
|
||||
#define S5P_JPGOPR 0x04
|
||||
|
||||
/* Quantization tables*/
|
||||
#define S5P_JPG_QTBL 0x08
|
||||
#define S5P_QT_NUMt_SHIFT(t) (((t) - 1) << 1)
|
||||
#define S5P_QT_NUMt_MASK(t) (0x3 << S5P_QT_NUMt_SHIFT(t))
|
||||
|
||||
/* Huffman tables */
|
||||
#define S5P_JPG_HTBL 0x0c
|
||||
#define S5P_HT_NUMt_AC_SHIFT(t) (((t) << 1) - 1)
|
||||
#define S5P_HT_NUMt_AC_MASK(t) (0x1 << S5P_HT_NUMt_AC_SHIFT(t))
|
||||
|
||||
#define S5P_HT_NUMt_DC_SHIFT(t) (((t) - 1) << 1)
|
||||
#define S5P_HT_NUMt_DC_MASK(t) (0x1 << S5P_HT_NUMt_DC_SHIFT(t))
|
||||
|
||||
/* JPEG restart interval register upper byte */
|
||||
#define S5P_JPGDRI_U 0x10
|
||||
|
||||
/* JPEG restart interval register lower byte */
|
||||
#define S5P_JPGDRI_L 0x14
|
||||
|
||||
/* JPEG vertical resolution register upper byte */
|
||||
#define S5P_JPGY_U 0x18
|
||||
|
||||
/* JPEG vertical resolution register lower byte */
|
||||
#define S5P_JPGY_L 0x1c
|
||||
|
||||
/* JPEG horizontal resolution register upper byte */
|
||||
#define S5P_JPGX_U 0x20
|
||||
|
||||
/* JPEG horizontal resolution register lower byte */
|
||||
#define S5P_JPGX_L 0x24
|
||||
|
||||
/* JPEG byte count register upper byte */
|
||||
#define S5P_JPGCNT_U 0x28
|
||||
|
||||
/* JPEG byte count register middle byte */
|
||||
#define S5P_JPGCNT_M 0x2c
|
||||
|
||||
/* JPEG byte count register lower byte */
|
||||
#define S5P_JPGCNT_L 0x30
|
||||
|
||||
/* JPEG interrupt setting register */
|
||||
#define S5P_JPGINTSE 0x34
|
||||
#define S5P_RSTm_INT_EN_MASK (0x1 << 7)
|
||||
#define S5P_RSTm_INT_EN (0x1 << 7)
|
||||
#define S5P_DATA_NUM_INT_EN_MASK (0x1 << 6)
|
||||
#define S5P_DATA_NUM_INT_EN (0x1 << 6)
|
||||
#define S5P_FINAL_MCU_NUM_INT_EN_MASK (0x1 << 5)
|
||||
#define S5P_FINAL_MCU_NUM_INT_EN (0x1 << 5)
|
||||
|
||||
/* JPEG interrupt status register */
|
||||
#define S5P_JPGINTST 0x38
|
||||
#define S5P_RESULT_STAT_SHIFT 6
|
||||
#define S5P_RESULT_STAT_MASK (0x1 << S5P_RESULT_STAT_SHIFT)
|
||||
#define S5P_STREAM_STAT_SHIFT 5
|
||||
#define S5P_STREAM_STAT_MASK (0x1 << S5P_STREAM_STAT_SHIFT)
|
||||
|
||||
/* JPEG command register */
|
||||
#define S5P_JPGCOM 0x4c
|
||||
#define S5P_INT_RELEASE (0x1 << 2)
|
||||
|
||||
/* Raw image data r/w address register */
|
||||
#define S5P_JPG_IMGADR 0x50
|
||||
|
||||
/* JPEG file r/w address register */
|
||||
#define S5P_JPG_JPGADR 0x58
|
||||
|
||||
/* Coefficient for RGB-to-YCbCr converter register */
|
||||
#define S5P_JPG_COEF(n) (0x5c + (((n) - 1) << 2))
|
||||
#define S5P_COEFn_SHIFT(j) ((3 - (j)) << 3)
|
||||
#define S5P_COEFn_MASK(j) (0xff << S5P_COEFn_SHIFT(j))
|
||||
|
||||
/* JPEG color mode register */
|
||||
#define S5P_JPGCMOD 0x68
|
||||
#define S5P_MOD_SEL_MASK (0x7 << 5)
|
||||
#define S5P_MOD_SEL_422 (0x1 << 5)
|
||||
#define S5P_MOD_SEL_565 (0x2 << 5)
|
||||
#define S5P_MODE_Y16_MASK (0x1 << 1)
|
||||
#define S5P_MODE_Y16 (0x1 << 1)
|
||||
|
||||
/* JPEG clock control register */
|
||||
#define S5P_JPGCLKCON 0x6c
|
||||
#define S5P_CLK_DOWN_READY (0x1 << 1)
|
||||
#define S5P_POWER_ON (0x1 << 0)
|
||||
|
||||
/* JPEG start register */
|
||||
#define S5P_JSTART 0x70
|
||||
|
||||
/* JPEG SW reset register */
|
||||
#define S5P_JPG_SW_RESET 0x78
|
||||
|
||||
/* JPEG timer setting register */
|
||||
#define S5P_JPG_TIMER_SE 0x7c
|
||||
#define S5P_TIMER_INT_EN_MASK (0x1 << 31)
|
||||
#define S5P_TIMER_INT_EN (0x1 << 31)
|
||||
#define S5P_TIMER_INIT_MASK 0x7fffffff
|
||||
|
||||
/* JPEG timer status register */
|
||||
#define S5P_JPG_TIMER_ST 0x80
|
||||
#define S5P_TIMER_INT_STAT_SHIFT 31
|
||||
#define S5P_TIMER_INT_STAT_MASK (0x1 << S5P_TIMER_INT_STAT_SHIFT)
|
||||
#define S5P_TIMER_CNT_SHIFT 0
|
||||
#define S5P_TIMER_CNT_MASK 0x7fffffff
|
||||
|
||||
/* JPEG decompression output format register */
|
||||
#define S5P_JPG_OUTFORM 0x88
|
||||
#define S5P_DEC_OUT_FORMAT_MASK (0x1 << 0)
|
||||
#define S5P_DEC_OUT_FORMAT_422 (0x0 << 0)
|
||||
#define S5P_DEC_OUT_FORMAT_420 (0x1 << 0)
|
||||
|
||||
/* JPEG version register */
|
||||
#define S5P_JPG_VERSION 0x8c
|
||||
|
||||
/* JPEG compressed stream size interrupt setting register */
|
||||
#define S5P_JPG_ENC_STREAM_INTSE 0x98
|
||||
#define S5P_ENC_STREAM_INT_MASK (0x1 << 24)
|
||||
#define S5P_ENC_STREAM_INT_EN (0x1 << 24)
|
||||
#define S5P_ENC_STREAM_BOUND_MASK 0xffffff
|
||||
|
||||
/* JPEG compressed stream size interrupt status register */
|
||||
#define S5P_JPG_ENC_STREAM_INTST 0x9c
|
||||
#define S5P_ENC_STREAM_INT_STAT_MASK 0x1
|
||||
|
||||
/* JPEG quantizer table register */
|
||||
#define S5P_JPG_QTBL_CONTENT(n) (0x400 + (n) * 0x100)
|
||||
|
||||
/* JPEG DC Huffman table register */
|
||||
#define S5P_JPG_HDCTBL(n) (0x800 + (n) * 0x400)
|
||||
|
||||
/* JPEG DC Huffman table register */
|
||||
#define S5P_JPG_HDCTBLG(n) (0x840 + (n) * 0x400)
|
||||
|
||||
/* JPEG AC Huffman table register */
|
||||
#define S5P_JPG_HACTBL(n) (0x880 + (n) * 0x400)
|
||||
|
||||
/* JPEG AC Huffman table register */
|
||||
#define S5P_JPG_HACTBLG(n) (0x8c0 + (n) * 0x400)
|
||||
|
||||
#endif /* JPEG_REGS_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user