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

Commit 6d843f0f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "media: dvb: add dvb video driver for msm8974/msm8092"

parents 91ed060a b3fc4c28
Loading
Loading
Loading
Loading
+1898 −1956

File changed.

Preview size limit exceeded, changes collapsed.

+139 −59
Original line number Diff line number Diff line
/* Copyright (c) 2010,2012, The Linux Foundation. All rights reserved.
/* Copyright (c) 2010, 2012-2013, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -10,84 +10,164 @@
 * GNU General Public License for more details.
 *
 */

#ifndef MPQ_DVB_VIDEO_INTERNAL_H
#define MPQ_DVB_VIDEO_INTERNAL_H

#include <linux/msm_vidc_dec.h>
#include <media/msm/vidc_init.h>
#include <linux/dvb/video.h>
#define MPQ_DBG_INFO  "mpq_video:%d "
#define MPQ_VID_DEC_NAME "mpq_vidc_dec"

/*
 * MPQ Specific Includes.
 */
#include "mpq_dvb_debug.h"
#include "mpq_adapter.h"
#include "mpq_stream_buffer.h"
extern int mpq_debug;

#define DVB_MPQ_NUM_VIDEO_DEVICES CONFIG_DVB_MPQ_NUM_VIDEO_DEVICES
enum {
	MPQ_ERR = 0x001,
	MPQ_WRN = 0x002,
	MPQ_INF = 0x004,
	MPQ_DBG = 0x008
};

/*
 * Input Buffer Requirements for Video Decoder.
 */
#define DVB_VID_NUM_IN_BUFFERS (2)
#define DVB_VID_IN_BUFFER_SIZE (2*1024*1024)
#define DVB_VID_IN_BUFFER_ALGN (8*1024)
#define dprintk(dbg_mask, fmt, arg...)    \
	do { \
		if (mpq_debug & dbg_mask) { \
			pr_debug(MPQ_DBG_INFO fmt, dbg_mask, ## arg); \
		} \
	} while (0)

struct vid_dec_msg {
	struct list_head list;
	struct vdec_msginfo vdec_msg_info;
#define DBG(x...)	dprintk(MPQ_DBG, ## x)
#define INF(x...)	dprintk(MPQ_INF, ## x)
#define WRN(x...)	dprintk(MPQ_WRN, ## x)
#define ERR(x...)	dprintk(MPQ_ERR, ## x)

#define DVB_MPQ_NUM_VIDEO_DEVICES	4
#define SAFE_GAP			16
#define MAX_NUM_BUFS			32

#define MPQ_DVB_INPUT_BUF_COUNT_BIT		0x00000001
#define MPQ_DVB_INPUT_BUF_REQ_BIT		0x00000002
#define MPQ_DVB_INPUT_BUF_SETUP_BIT		0x00000004
#define MPQ_DVB_OUTPUT_BUF_COUNT_BIT	0x00000008
#define MPQ_DVB_OUTPUT_BUF_REQ_BIT		0x00000010
#define MPQ_DVB_OUTPUT_BUF_SETUP_BIT	0x00000020
#define MPQ_DVB_INPUT_STREAMON_BIT		0x00000040
#define MPQ_DVB_OUTPUT_STREAMON_BIT		0x00000080
#define MPQ_DVB_FLUSH_DONE_BIT			0x00000100

#define DEFAULT_INPUT_BUF_SIZE	        (1024*1024)
#define DEFAULT_INPUT_BUF_NUM		16

#define EXTRADATA_IDX(__num_planes) (__num_planes - 1)

enum {
	OUTPUT_PORT = 0,
	CAPTURE_PORT,
	MAX_PORTS
};

enum {
	INPUT_MODE_LINEAR,
	INPUT_MODE_RING
};

enum mpq_bcast_msgcode {
	MPQ_BCAST_MSG_START,
	MPQ_BCAST_MSG_IBD,
	MPQ_BCAST_MSG_FLUSH,
	MPQ_BCAST_MSG_TERM
enum {
	MPQ_MSG_OUTPUT_BUFFER_DONE,
	MPQ_MSG_VIDC_EVENT
};

struct mpq_bcast_msg_info {
	enum mpq_bcast_msgcode code;
	unsigned int data;
enum {
	MPQ_STATE_INIT,
	MPQ_STATE_READY,
	MPQ_STATE_RUNNING,
	MPQ_STATE_IDLE,
	MPQ_STATE_CLOSED
};

struct mpq_bcast_msg {
struct mpq_inq_msg {
	struct list_head	list;
	struct mpq_bcast_msg_info info;
	u32			buf_index;
};

struct mpq_dmx_src_data {
	struct mpq_streambuffer *stream_buffer;
	struct video_data_buffer in_buffer[DVB_VID_NUM_IN_BUFFERS];
struct mpq_outq_msg {
	struct list_head	list;
	u32			type;
	struct video_event	vidc_event;
};

struct mpq_msg_q_msg {
	struct list_head	list;
	u32			msg_type;
};

struct buffer_info {
	int			index;
	enum v4l2_buf_type	buf_type;
	u32			size;
	u32			offset;
	u32			bytesused;
	u32			vaddr;
	int			fd;
	u32			dev_addr;
	u32			kernel_vaddr;
	u32			buf_offset;
	struct msm_smem     *handle;
};

struct mpq_ring_buffer {
	struct buffer_info	buf;
	size_t			len;
	size_t			write_idx;
	size_t			read_idx;
	size_t			release_idx;
	wait_queue_head_t	write_wait;
	wait_queue_head_t	read_wait;
	struct semaphore	sem;
};

struct v4l2_instance {
	struct msm_vidc_instance	*vidc_inst;
	void	                    *mem_client;
	struct mutex                lock;
	struct list_head			msg_queue;
	struct semaphore			msg_sem;
	wait_queue_head_t			msg_wait;
	struct mutex msg_queue_lock;
	struct task_struct *data_task;
	struct list_head			inq;
	struct semaphore			inq_sem;
	wait_queue_head_t			inq_wait;
	struct list_head			outq;
	struct semaphore			outq_sem;
	wait_queue_head_t			outq_wait;
	struct v4l2_requestbuffers	bufreq[MAX_PORTS];
	struct v4l2_format			fmt[MAX_PORTS];
	u32							input_mode;
	struct mpq_ring_buffer	    *ringbuf;
	u32		num_input_buffers;
	u32		input_buf_count;
	u32		num_output_buffers;
	u32		output_buf_count;
	u32		flag;
	u32		state;
	struct buffer_info buf_info[MAX_PORTS][MAX_NUM_BUFS];
};

struct mpq_dvb_video_inst {
struct mpq_dmx_source {
	struct mpq_streambuffer *stream_buffer;
};

struct mpq_dvb_video_instance {
	struct dvb_device			*video_dev;
	video_stream_source_t		source;
	struct mpq_dmx_src_data *dmx_src_data;
	struct video_client_ctx *client_ctx;
	struct mpq_dmx_source		*dmx_src_data;
	struct v4l2_instance		*v4l2_inst;
	struct task_struct			*input_task;
	struct task_struct			*event_task;
	struct task_struct			*demux_task;
};

struct mpq_dvb_video_dev {

	resource_size_t phys_base;
	void __iomem *virt_base;
	unsigned int irq;
	struct clk *hclk;
	struct clk *hclk_div2;
	struct clk *pclk;
	unsigned long hclk_rate;
	struct mutex lock;
struct mpq_dvb_video_device {
	s32						device_handle;
	struct dvb_adapter *mpq_adapter;
	struct mpq_dvb_video_inst dev_inst[DVB_MPQ_NUM_VIDEO_DEVICES];
	struct video_client_ctx vdec_clients[DVB_MPQ_NUM_VIDEO_DEVICES];
	u32						num_clients;
	void(*timer_handler)(void *);
	struct mutex			lock;
	struct dvb_adapter		*mpq_adapter;
	struct mpq_dvb_video_instance	dev_inst[DVB_MPQ_NUM_VIDEO_DEVICES];
	struct ion_client				*ion_clnt;
};

#endif /* MPQ_DVB_VIDEO_INTERNAL_H */