Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bb677f3a authored by Andrzej Pietrasiewicz's avatar Andrzej Pietrasiewicz Committed by Mauro Carvalho Chehab
Browse files

[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: default avatarAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: default avatarSakari Ailus <sakari.ailus@iki.fi>
Reviewed-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Reviewed-by: default avatarTomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent aa73ab96
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
s5p-jpeg-objs := jpeg-core.o
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) := s5p-jpeg.o
+1481 −0

File added.

Preview size limit exceeded, changes collapsed.

+143 −0
Original line number Diff line number Diff line
/* 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 */
Loading