2014-07-23 15:28:39 +00:00
|
|
|
/*
|
|
|
|
* Coda multi-standard codec IP
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Vista Silicon S.L.
|
|
|
|
* Javier Martin, <javier.martin@vista-silicon.com>
|
|
|
|
* Xavier Duret
|
|
|
|
* Copyright (C) 2012-2014 Philipp Zabel, Pengutronix
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
2015-01-29 17:36:00 +00:00
|
|
|
#ifndef __CODA_H__
|
|
|
|
#define __CODA_H__
|
|
|
|
|
2014-07-23 15:28:39 +00:00
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include <linux/irqreturn.h>
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/kfifo.h>
|
|
|
|
#include <linux/videodev2.h>
|
|
|
|
|
|
|
|
#include <media/v4l2-ctrls.h>
|
|
|
|
#include <media/v4l2-device.h>
|
|
|
|
#include <media/v4l2-fh.h>
|
2015-09-22 13:30:29 +00:00
|
|
|
#include <media/videobuf2-v4l2.h>
|
2014-07-23 15:28:39 +00:00
|
|
|
|
|
|
|
#include "coda_regs.h"
|
|
|
|
|
|
|
|
#define CODA_MAX_FRAMEBUFFERS 8
|
|
|
|
#define FMO_SLICE_SAVE_BUF_SIZE (32)
|
|
|
|
|
|
|
|
enum {
|
|
|
|
V4L2_M2M_SRC = 0,
|
|
|
|
V4L2_M2M_DST = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum coda_inst_type {
|
|
|
|
CODA_INST_ENCODER,
|
|
|
|
CODA_INST_DECODER,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum coda_product {
|
|
|
|
CODA_DX6 = 0xf001,
|
|
|
|
CODA_7541 = 0xf012,
|
|
|
|
CODA_960 = 0xf020,
|
|
|
|
};
|
|
|
|
|
2014-10-02 17:08:28 +00:00
|
|
|
struct coda_video_device;
|
|
|
|
|
2014-07-23 15:28:39 +00:00
|
|
|
struct coda_devtype {
|
2016-02-19 09:18:57 +00:00
|
|
|
char *firmware[2];
|
2014-07-23 15:28:39 +00:00
|
|
|
enum coda_product product;
|
|
|
|
const struct coda_codec *codecs;
|
|
|
|
unsigned int num_codecs;
|
2014-10-02 17:08:28 +00:00
|
|
|
const struct coda_video_device **vdevs;
|
|
|
|
unsigned int num_vdevs;
|
2014-07-23 15:28:39 +00:00
|
|
|
size_t workbuf_size;
|
|
|
|
size_t tempbuf_size;
|
|
|
|
size_t iram_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct coda_aux_buf {
|
|
|
|
void *vaddr;
|
|
|
|
dma_addr_t paddr;
|
|
|
|
u32 size;
|
|
|
|
struct debugfs_blob_wrapper blob;
|
|
|
|
struct dentry *dentry;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct coda_dev {
|
|
|
|
struct v4l2_device v4l2_dev;
|
2014-10-02 17:08:31 +00:00
|
|
|
struct video_device vfd[5];
|
2014-07-23 15:28:39 +00:00
|
|
|
struct platform_device *plat_dev;
|
|
|
|
const struct coda_devtype *devtype;
|
2016-02-19 09:18:57 +00:00
|
|
|
int firmware;
|
2014-07-23 15:28:39 +00:00
|
|
|
|
|
|
|
void __iomem *regs_base;
|
|
|
|
struct clk *clk_per;
|
|
|
|
struct clk *clk_ahb;
|
|
|
|
struct reset_control *rstc;
|
|
|
|
|
|
|
|
struct coda_aux_buf codebuf;
|
|
|
|
struct coda_aux_buf tempbuf;
|
|
|
|
struct coda_aux_buf workbuf;
|
|
|
|
struct gen_pool *iram_pool;
|
|
|
|
struct coda_aux_buf iram;
|
|
|
|
|
|
|
|
spinlock_t irqlock;
|
|
|
|
struct mutex dev_mutex;
|
|
|
|
struct mutex coda_mutex;
|
|
|
|
struct workqueue_struct *workqueue;
|
|
|
|
struct v4l2_m2m_dev *m2m_dev;
|
|
|
|
struct list_head instances;
|
|
|
|
unsigned long instance_mask;
|
|
|
|
struct dentry *debugfs_root;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct coda_codec {
|
|
|
|
u32 mode;
|
|
|
|
u32 src_fourcc;
|
|
|
|
u32 dst_fourcc;
|
|
|
|
u32 max_w;
|
|
|
|
u32 max_h;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct coda_huff_tab;
|
|
|
|
|
|
|
|
struct coda_params {
|
|
|
|
u8 rot_mode;
|
|
|
|
u8 h264_intra_qp;
|
|
|
|
u8 h264_inter_qp;
|
|
|
|
u8 h264_min_qp;
|
|
|
|
u8 h264_max_qp;
|
|
|
|
u8 h264_deblk_enabled;
|
|
|
|
u8 h264_deblk_alpha;
|
|
|
|
u8 h264_deblk_beta;
|
|
|
|
u8 mpeg4_intra_qp;
|
|
|
|
u8 mpeg4_inter_qp;
|
|
|
|
u8 gop_size;
|
|
|
|
int intra_refresh;
|
2014-10-02 17:08:31 +00:00
|
|
|
u8 jpeg_quality;
|
|
|
|
u8 jpeg_restart_interval;
|
|
|
|
u8 *jpeg_qmat_tab[3];
|
2014-07-23 15:28:39 +00:00
|
|
|
int codec_mode;
|
|
|
|
int codec_mode_aux;
|
|
|
|
enum v4l2_mpeg_video_multi_slice_mode slice_mode;
|
|
|
|
u32 framerate;
|
|
|
|
u16 bitrate;
|
2015-07-10 13:37:52 +00:00
|
|
|
u16 vbv_delay;
|
|
|
|
u32 vbv_size;
|
2014-07-23 15:28:39 +00:00
|
|
|
u32 slice_max_bits;
|
|
|
|
u32 slice_max_mb;
|
|
|
|
};
|
|
|
|
|
2014-10-02 17:08:32 +00:00
|
|
|
struct coda_buffer_meta {
|
2014-07-23 15:28:39 +00:00
|
|
|
struct list_head list;
|
|
|
|
u32 sequence;
|
|
|
|
struct v4l2_timecode timecode;
|
2015-11-03 10:16:37 +00:00
|
|
|
u64 timestamp;
|
2014-10-02 17:08:32 +00:00
|
|
|
u32 start;
|
|
|
|
u32 end;
|
2014-07-23 15:28:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Per-queue, driver-specific private data */
|
|
|
|
struct coda_q_data {
|
|
|
|
unsigned int width;
|
|
|
|
unsigned int height;
|
|
|
|
unsigned int bytesperline;
|
|
|
|
unsigned int sizeimage;
|
|
|
|
unsigned int fourcc;
|
|
|
|
struct v4l2_rect rect;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct coda_iram_info {
|
|
|
|
u32 axi_sram_use;
|
|
|
|
phys_addr_t buf_bit_use;
|
|
|
|
phys_addr_t buf_ip_ac_dc_use;
|
|
|
|
phys_addr_t buf_dbk_y_use;
|
|
|
|
phys_addr_t buf_dbk_c_use;
|
|
|
|
phys_addr_t buf_ovl_use;
|
|
|
|
phys_addr_t buf_btp_use;
|
|
|
|
phys_addr_t search_ram_paddr;
|
|
|
|
int search_ram_size;
|
|
|
|
int remaining;
|
|
|
|
phys_addr_t next_paddr;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GDI_LINEAR_FRAME_MAP 0
|
2015-07-16 16:19:38 +00:00
|
|
|
#define GDI_TILED_FRAME_MB_RASTER_MAP 1
|
2014-07-23 15:28:39 +00:00
|
|
|
|
2014-07-23 15:28:40 +00:00
|
|
|
struct coda_ctx;
|
|
|
|
|
|
|
|
struct coda_context_ops {
|
|
|
|
int (*queue_init)(void *priv, struct vb2_queue *src_vq,
|
|
|
|
struct vb2_queue *dst_vq);
|
2015-03-24 17:30:51 +00:00
|
|
|
int (*reqbufs)(struct coda_ctx *ctx, struct v4l2_requestbuffers *rb);
|
2014-07-23 15:28:40 +00:00
|
|
|
int (*start_streaming)(struct coda_ctx *ctx);
|
|
|
|
int (*prepare_run)(struct coda_ctx *ctx);
|
|
|
|
void (*finish_run)(struct coda_ctx *ctx);
|
|
|
|
void (*seq_end_work)(struct work_struct *work);
|
|
|
|
void (*release)(struct coda_ctx *ctx);
|
|
|
|
};
|
|
|
|
|
2014-07-23 15:28:39 +00:00
|
|
|
struct coda_ctx {
|
|
|
|
struct coda_dev *dev;
|
|
|
|
struct mutex buffer_mutex;
|
|
|
|
struct list_head list;
|
|
|
|
struct work_struct pic_run_work;
|
|
|
|
struct work_struct seq_end_work;
|
|
|
|
struct completion completion;
|
2014-10-02 17:08:28 +00:00
|
|
|
const struct coda_video_device *cvd;
|
2014-07-23 15:28:40 +00:00
|
|
|
const struct coda_context_ops *ops;
|
2014-07-23 15:28:39 +00:00
|
|
|
int aborting;
|
|
|
|
int initialized;
|
|
|
|
int streamon_out;
|
|
|
|
int streamon_cap;
|
|
|
|
u32 qsequence;
|
|
|
|
u32 osequence;
|
|
|
|
u32 sequence_offset;
|
|
|
|
struct coda_q_data q_data[2];
|
|
|
|
enum coda_inst_type inst_type;
|
|
|
|
const struct coda_codec *codec;
|
|
|
|
enum v4l2_colorspace colorspace;
|
|
|
|
struct coda_params params;
|
|
|
|
struct v4l2_ctrl_handler ctrls;
|
|
|
|
struct v4l2_fh fh;
|
|
|
|
int gopcounter;
|
|
|
|
int runcounter;
|
|
|
|
char vpu_header[3][64];
|
|
|
|
int vpu_header_size[3];
|
|
|
|
struct kfifo bitstream_fifo;
|
|
|
|
struct mutex bitstream_mutex;
|
|
|
|
struct coda_aux_buf bitstream;
|
|
|
|
bool hold;
|
|
|
|
struct coda_aux_buf parabuf;
|
|
|
|
struct coda_aux_buf psbuf;
|
|
|
|
struct coda_aux_buf slicebuf;
|
|
|
|
struct coda_aux_buf internal_frames[CODA_MAX_FRAMEBUFFERS];
|
|
|
|
u32 frame_types[CODA_MAX_FRAMEBUFFERS];
|
2014-10-02 17:08:32 +00:00
|
|
|
struct coda_buffer_meta frame_metas[CODA_MAX_FRAMEBUFFERS];
|
2014-07-23 15:28:39 +00:00
|
|
|
u32 frame_errors[CODA_MAX_FRAMEBUFFERS];
|
2014-10-02 17:08:32 +00:00
|
|
|
struct list_head buffer_meta_list;
|
2015-07-09 10:10:21 +00:00
|
|
|
spinlock_t buffer_meta_lock;
|
|
|
|
int num_metas;
|
2014-07-23 15:28:39 +00:00
|
|
|
struct coda_aux_buf workbuf;
|
|
|
|
int num_internal_frames;
|
|
|
|
int idx;
|
|
|
|
int reg_idx;
|
|
|
|
struct coda_iram_info iram_info;
|
2015-07-16 16:19:38 +00:00
|
|
|
int tiled_map_type;
|
2014-07-23 15:28:39 +00:00
|
|
|
u32 bit_stream_param;
|
|
|
|
u32 frm_dis_flg;
|
|
|
|
u32 frame_mem_ctrl;
|
|
|
|
int display_idx;
|
|
|
|
struct dentry *debugfs_entry;
|
2015-01-23 16:51:33 +00:00
|
|
|
bool use_bit;
|
2014-07-23 15:28:39 +00:00
|
|
|
};
|
2014-07-23 15:28:44 +00:00
|
|
|
|
2014-07-23 15:28:45 +00:00
|
|
|
extern int coda_debug;
|
|
|
|
|
|
|
|
void coda_write(struct coda_dev *dev, u32 data, u32 reg);
|
|
|
|
unsigned int coda_read(struct coda_dev *dev, u32 reg);
|
2014-09-29 12:53:44 +00:00
|
|
|
void coda_write_base(struct coda_ctx *ctx, struct coda_q_data *q_data,
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 13:30:30 +00:00
|
|
|
struct vb2_v4l2_buffer *buf, unsigned int reg_y);
|
2014-07-23 15:28:45 +00:00
|
|
|
|
|
|
|
int coda_alloc_aux_buf(struct coda_dev *dev, struct coda_aux_buf *buf,
|
|
|
|
size_t size, const char *name, struct dentry *parent);
|
|
|
|
void coda_free_aux_buf(struct coda_dev *dev, struct coda_aux_buf *buf);
|
|
|
|
|
|
|
|
int coda_encoder_queue_init(void *priv, struct vb2_queue *src_vq,
|
|
|
|
struct vb2_queue *dst_vq);
|
|
|
|
int coda_decoder_queue_init(void *priv, struct vb2_queue *src_vq,
|
|
|
|
struct vb2_queue *dst_vq);
|
|
|
|
|
|
|
|
int coda_hw_reset(struct coda_ctx *ctx);
|
|
|
|
|
2015-03-24 17:30:57 +00:00
|
|
|
void coda_fill_bitstream(struct coda_ctx *ctx, bool streaming);
|
2014-07-23 15:28:45 +00:00
|
|
|
|
|
|
|
void coda_set_gdi_regs(struct coda_ctx *ctx);
|
|
|
|
|
|
|
|
static inline struct coda_q_data *get_q_data(struct coda_ctx *ctx,
|
|
|
|
enum v4l2_buf_type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
|
|
|
|
return &(ctx->q_data[V4L2_M2M_SRC]);
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
|
|
|
|
return &(ctx->q_data[V4L2_M2M_DST]);
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *coda_product_name(int product);
|
|
|
|
|
|
|
|
int coda_check_firmware(struct coda_dev *dev);
|
|
|
|
|
2015-03-24 17:30:49 +00:00
|
|
|
static inline unsigned int coda_get_bitstream_payload(struct coda_ctx *ctx)
|
2014-07-23 15:28:45 +00:00
|
|
|
{
|
|
|
|
return kfifo_len(&ctx->bitstream_fifo);
|
|
|
|
}
|
|
|
|
|
|
|
|
void coda_bit_stream_end_flag(struct coda_ctx *ctx);
|
|
|
|
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 13:30:30 +00:00
|
|
|
void coda_m2m_buf_done(struct coda_ctx *ctx, struct vb2_v4l2_buffer *buf,
|
2015-05-04 10:51:07 +00:00
|
|
|
enum vb2_buffer_state state);
|
|
|
|
|
2014-07-23 15:28:44 +00:00
|
|
|
int coda_h264_padding(int size, char *p);
|
2014-07-23 15:28:45 +00:00
|
|
|
|
2015-12-02 16:58:51 +00:00
|
|
|
bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_buffer *vb);
|
2014-10-02 17:08:31 +00:00
|
|
|
int coda_jpeg_write_tables(struct coda_ctx *ctx);
|
|
|
|
void coda_set_jpeg_compression_quality(struct coda_ctx *ctx, int quality);
|
|
|
|
|
2014-07-23 15:28:45 +00:00
|
|
|
extern const struct coda_context_ops coda_bit_encode_ops;
|
|
|
|
extern const struct coda_context_ops coda_bit_decode_ops;
|
|
|
|
|
|
|
|
irqreturn_t coda_irq_handler(int irq, void *data);
|
2015-01-29 17:36:00 +00:00
|
|
|
|
|
|
|
#endif /* __CODA_H__ */
|