linux/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c

// SPDX-License-Identifier: GPL-2.0-only
/* linux/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
 *
 * Copyright (c) 2011-2014 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com
 *
 * Author: Andrzej Pietrasiewicz <[email protected]>
 * Author: Jacek Anaszewski <[email protected]>
 */

#include <linux/clk.h>
#include <linux/err.h>
#include <linux/gfp.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <media/v4l2-event.h>
#include <media/v4l2-mem2mem.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-rect.h>
#include <media/videobuf2-v4l2.h>
#include <media/videobuf2-dma-contig.h>

#include "jpeg-core.h"
#include "jpeg-hw-s5p.h"
#include "jpeg-hw-exynos4.h"
#include "jpeg-hw-exynos3250.h"
#include "jpeg-regs.h"

static struct s5p_jpeg_fmt sjpeg_formats[] =;
#define SJPEG_NUM_FORMATS

static const unsigned char qtbl_luminance[4][64] =;

static const unsigned char qtbl_chrominance[4][64] =;

static const unsigned char hdctbl0[16] =;

static const unsigned char hdctblg0[12] =;
static const unsigned char hactbl0[16] =;
static const unsigned char hactblg0[162] =;

/*
 * Fourcc downgrade schema lookup tables for 422 and 420
 * chroma subsampling - fourcc on each position maps on the
 * fourcc from the table fourcc_to_dwngrd_schema_id which allows
 * to get the most suitable fourcc counterpart for the given
 * downgraded subsampling property.
 */
static const u32 subs422_fourcc_dwngrd_schema[] =;

static const u32 subs420_fourcc_dwngrd_schema[] =;

/*
 * Lookup table for translation of a fourcc to the position
 * of its downgraded counterpart in the *fourcc_dwngrd_schema
 * tables.
 */
static const u32 fourcc_to_dwngrd_schema_id[] =;

static int s5p_jpeg_get_dwngrd_sch_id_by_fourcc(u32 fourcc)
{}

static int s5p_jpeg_adjust_fourcc_to_subsampling(
					enum v4l2_jpeg_chroma_subsampling subs,
					u32 in_fourcc,
					u32 *out_fourcc,
					struct s5p_jpeg_ctx *ctx)
{}

static int exynos4x12_decoded_subsampling[] =;

static int exynos3250_decoded_subsampling[] =;

static inline struct s5p_jpeg_ctx *ctrl_to_ctx(struct v4l2_ctrl *c)
{}

static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh)
{}

static int s5p_jpeg_to_user_subsampling(struct s5p_jpeg_ctx *ctx)
{}

static inline void s5p_jpeg_set_qtbl(void __iomem *regs,
				     const unsigned char *qtbl,
				     unsigned long tab, int len)
{}

static inline void s5p_jpeg_set_qtbl_lum(void __iomem *regs, int quality)
{}

static inline void s5p_jpeg_set_qtbl_chr(void __iomem *regs, int quality)
{}

static inline void s5p_jpeg_set_htbl(void __iomem *regs,
				     const unsigned char *htbl,
				     unsigned long tab, int len)
{}

static inline void s5p_jpeg_set_hdctbl(void __iomem *regs)
{}

static inline void s5p_jpeg_set_hdctblg(void __iomem *regs)
{}

static inline void s5p_jpeg_set_hactbl(void __iomem *regs)
{}

static inline void s5p_jpeg_set_hactblg(void __iomem *regs)
{}

static inline void exynos4_jpeg_set_tbl(void __iomem *regs,
					const unsigned char *tbl,
					unsigned long tab, int len)
{}

static inline void exynos4_jpeg_set_qtbl_lum(void __iomem *regs, int quality)
{}

static inline void exynos4_jpeg_set_qtbl_chr(void __iomem *regs, int quality)
{}

static void exynos4_jpeg_set_huff_tbl(void __iomem *base)
{}

static inline int __exynos4_huff_tbl(int class, int id, bool lenval)
{}

static inline int exynos4_huff_tbl_len(int class, int id)
{}

static inline int exynos4_huff_tbl_val(int class, int id)
{}

static int get_byte(struct s5p_jpeg_buffer *buf);
static int get_word_be(struct s5p_jpeg_buffer *buf, unsigned int *word);
static void skip(struct s5p_jpeg_buffer *buf, long len);

static void exynos4_jpeg_parse_decode_h_tbl(struct s5p_jpeg_ctx *ctx)
{}

static void exynos4_jpeg_parse_huff_tbl(struct s5p_jpeg_ctx *ctx)
{}

static void exynos4_jpeg_parse_decode_q_tbl(struct s5p_jpeg_ctx *ctx)
{}

static void exynos4_jpeg_parse_q_tbl(struct s5p_jpeg_ctx *ctx)
{}

/*
 * ============================================================================
 * Device file operations
 * ============================================================================
 */

static int queue_init(void *priv, struct vb2_queue *src_vq,
		      struct vb2_queue *dst_vq);
static struct s5p_jpeg_fmt *s5p_jpeg_find_format(struct s5p_jpeg_ctx *ctx,
				__u32 pixelformat, unsigned int fmt_type);
static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx);

static int s5p_jpeg_open(struct file *file)
{}

static int s5p_jpeg_release(struct file *file)
{}

static const struct v4l2_file_operations s5p_jpeg_fops =;

/*
 * ============================================================================
 * video ioctl operations
 * ============================================================================
 */

static int get_byte(struct s5p_jpeg_buffer *buf)
{}

static int get_word_be(struct s5p_jpeg_buffer *buf, unsigned int *word)
{}

static void skip(struct s5p_jpeg_buffer *buf, long len)
{}

static bool s5p_jpeg_subsampling_decode(struct s5p_jpeg_ctx *ctx,
					unsigned int subsampling)
{}

static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
			       unsigned long buffer, unsigned long size,
			       struct s5p_jpeg_ctx *ctx)
{}

static int s5p_jpeg_querycap(struct file *file, void *priv,
			   struct v4l2_capability *cap)
{}

static int enum_fmt(struct s5p_jpeg_ctx *ctx,
		    struct s5p_jpeg_fmt *sjpeg_formats, int n,
		    struct v4l2_fmtdesc *f, u32 type)
{}

static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
				   struct v4l2_fmtdesc *f)
{}

static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
				   struct v4l2_fmtdesc *f)
{}

static struct s5p_jpeg_q_data *get_q_data(struct s5p_jpeg_ctx *ctx,
					  enum v4l2_buf_type type)
{}

static int s5p_jpeg_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
{}

static struct s5p_jpeg_fmt *s5p_jpeg_find_format(struct s5p_jpeg_ctx *ctx,
				u32 pixelformat, unsigned int fmt_type)
{}

static void jpeg_bound_align_image(struct s5p_jpeg_ctx *ctx,
				   u32 *w, unsigned int wmin, unsigned int wmax,
				   unsigned int walign,
				   u32 *h, unsigned int hmin, unsigned int hmax,
				   unsigned int halign)
{}

static int vidioc_try_fmt(struct v4l2_format *f, struct s5p_jpeg_fmt *fmt,
			  struct s5p_jpeg_ctx *ctx, int q_type)
{}

static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv,
				  struct v4l2_format *f)
{}

static int s5p_jpeg_try_fmt_vid_out(struct file *file, void *priv,
				  struct v4l2_format *f)
{}

static int exynos4_jpeg_get_output_buffer_size(struct s5p_jpeg_ctx *ctx,
						struct v4l2_format *f,
						int fmt_depth)
{}

static int exynos3250_jpeg_try_downscale(struct s5p_jpeg_ctx *ctx,
				   struct v4l2_rect *r);

static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f)
{}

static int s5p_jpeg_s_fmt_vid_cap(struct file *file, void *priv,
				struct v4l2_format *f)
{}

static int s5p_jpeg_s_fmt_vid_out(struct file *file, void *priv,
				struct v4l2_format *f)
{}

static int s5p_jpeg_subscribe_event(struct v4l2_fh *fh,
				    const struct v4l2_event_subscription *sub)
{}

static int exynos3250_jpeg_try_downscale(struct s5p_jpeg_ctx *ctx,
				   struct v4l2_rect *r)
{}

static int exynos3250_jpeg_try_crop(struct s5p_jpeg_ctx *ctx,
				   struct v4l2_rect *r)
{}

/*
 * V4L2 controls
 */

static int s5p_jpeg_g_selection(struct file *file, void *priv,
			 struct v4l2_selection *s)
{}

/*
 * V4L2 controls
 */
static int s5p_jpeg_s_selection(struct file *file, void *fh,
				  struct v4l2_selection *s)
{}

static int s5p_jpeg_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
{}

static int s5p_jpeg_adjust_subs_ctrl(struct s5p_jpeg_ctx *ctx, int *ctrl_val)
{}

static int s5p_jpeg_try_ctrl(struct v4l2_ctrl *ctrl)
{}

static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl)
{}

static const struct v4l2_ctrl_ops s5p_jpeg_ctrl_ops =;

static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx)
{}

static const struct v4l2_ioctl_ops s5p_jpeg_ioctl_ops =;

/*
 * ============================================================================
 * mem2mem callbacks
 * ============================================================================
 */

static void s5p_jpeg_device_run(void *priv)
{}

static void exynos4_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
{}

static void exynos4_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx)
{}

static inline void exynos4_jpeg_set_img_fmt(void __iomem *base,
					    unsigned int img_fmt)
{}

static inline void exynos5433_jpeg_set_img_fmt(void __iomem *base,
					       unsigned int img_fmt)
{}

static inline void exynos4_jpeg_set_enc_out_fmt(void __iomem *base,
						unsigned int out_fmt)
{}

static inline void exynos5433_jpeg_set_enc_out_fmt(void __iomem *base,
						   unsigned int out_fmt)
{}

static void exynos4_jpeg_device_run(void *priv)
{}

static void exynos3250_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
{}

static void exynos3250_jpeg_set_jpeg_addr(struct s5p_jpeg_ctx *ctx)
{}

static void exynos3250_jpeg_device_run(void *priv)
{}

static int s5p_jpeg_job_ready(void *priv)
{}

static const struct v4l2_m2m_ops s5p_jpeg_m2m_ops =;

static const struct v4l2_m2m_ops exynos3250_jpeg_m2m_ops =;

static const struct v4l2_m2m_ops exynos4_jpeg_m2m_ops =;

/*
 * ============================================================================
 * Queue operations
 * ============================================================================
 */

static int s5p_jpeg_queue_setup(struct vb2_queue *vq,
			   unsigned int *nbuffers, unsigned int *nplanes,
			   unsigned int sizes[], struct device *alloc_devs[])
{}

static int s5p_jpeg_buf_prepare(struct vb2_buffer *vb)
{}

static void s5p_jpeg_set_capture_queue_data(struct s5p_jpeg_ctx *ctx)
{}

static void s5p_jpeg_buf_queue(struct vb2_buffer *vb)
{}

static int s5p_jpeg_start_streaming(struct vb2_queue *q, unsigned int count)
{}

static void s5p_jpeg_stop_streaming(struct vb2_queue *q)
{}

static const struct vb2_ops s5p_jpeg_qops =;

static int queue_init(void *priv, struct vb2_queue *src_vq,
		      struct vb2_queue *dst_vq)
{}

/*
 * ============================================================================
 * ISR
 * ============================================================================
 */

static irqreturn_t s5p_jpeg_irq(int irq, void *dev_id)
{}

static irqreturn_t exynos4_jpeg_irq(int irq, void *priv)
{}

static irqreturn_t exynos3250_jpeg_irq(int irq, void *dev_id)
{}

static void *jpeg_get_drv_data(struct device *dev);

/*
 * ============================================================================
 * Driver basic infrastructure
 * ============================================================================
 */

static int s5p_jpeg_probe(struct platform_device *pdev)
{}

static void s5p_jpeg_remove(struct platform_device *pdev)
{}

#ifdef CONFIG_PM
static int s5p_jpeg_runtime_suspend(struct device *dev)
{}

static int s5p_jpeg_runtime_resume(struct device *dev)
{}
#endif /* CONFIG_PM */

static const struct dev_pm_ops s5p_jpeg_pm_ops =;

static struct s5p_jpeg_variant s5p_jpeg_drvdata =;

static struct s5p_jpeg_variant exynos3250_jpeg_drvdata =;

static struct s5p_jpeg_variant exynos4_jpeg_drvdata =;

static struct s5p_jpeg_variant exynos5420_jpeg_drvdata =;

static struct s5p_jpeg_variant exynos5433_jpeg_drvdata =;

static const struct of_device_id samsung_jpeg_match[] =;

MODULE_DEVICE_TABLE(of, samsung_jpeg_match);

static void *jpeg_get_drv_data(struct device *dev)
{}

static struct platform_driver s5p_jpeg_driver =;

module_platform_driver();

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();