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

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

Merge "Migrate mpq demux driver from kernel 3.10 to 3.18"

parents dd4533c8 e2fe825f
Loading
Loading
Loading
Loading
+93 −0
Original line number Diff line number Diff line
TSPP Driver

For information on the TSPP driver, please refer to the TSPP driver
documentation: Documentation/arm/msm/tspp.txt.

The devicetree representation of the TSPP block should be:

Required properties:

- compatible: "qcom,msm_tspp"
- reg: physical memory base addresses and sizes for the following:
	TSIF0, TSIF1, TSPP and TSPP_BAM.
- reg-names: names of the memory regions.
- interrupts: represents IRQ numbers for the following:
	TSIF_TSPP_IRQ, TSIF0_IRQ, TSIF1_IRQ, TSIF_BAM_IRQ.
- interrupt-names: TSPP, TSIF and BAM interrupt names.
- pinctrl-names: the names of the pinctrl states that are used by the driver to
	configure the TLMM pins. The allowed states are:
	disabled - both tsif inputs are not used
	tsif0-mode1 - only tsif0 is active in mode 1 (no sync signal)
	tsif0-mode2 - only tsif0 is used in mode 2 (with sync signal)
	tsif1-mode1 - only tsif1 is active in mode 1 (no sync signal)
	tsif1-mode2 - only tsif1 is used in mode 2 (with sync signal)
	dual-tsif-mode1 - both tsif0 and tsif1 are active, in mode 1
	dual-tsif-mode1 - both tsif0 and tsif1 are active, in mode 2
- pinctrl-#: a list of pinctrl phandles for the different pinctrl states. Refer
	to "Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt" for
	the pinctrl handles definitions. Each pinctrl-# corresponds to the
	respective state name that appears under pinctrl-state list.
	Note that when switching from one state to another, any pins in
	the old state which do not appear in the new state are automatically
	disabled by the pinctrl framework.

Optional properties:

- vdd_cx-supply: Reference to the regulator that supplies the CX rail.
	Some hardware platforms (e.g. 8974-v2) require the voltage of the rail
	supplying power to the TSIF hardware block to be elevated before
	enabling the TSIF clocks.
- Refer to "Documentation/devicetree/bindings/arm/msm/msm_bus.txt" for
	the below optional properties:
	- qcom,msm-bus,name
	- qcom,msm-bus,num-cases
	- qcom,msm-bus,num-paths
	- qcom,msm-bus,vectors-KBps

Example (for 8974 platform, avaialble at msm8974.dtsi):

	tspp: msm_tspp@f99d8000 {
		compatible = "qcom,msm_tspp";
		reg = <0xf99d8000 0x1000>, /* MSM_TSIF0_PHYS */
		      <0xf99d9000 0x1000>, /* MSM_TSIF1_PHYS */
		      <0xf99da000 0x1000>, /* MSM_TSPP_PHYS  */
		      <0xf99c4000 0x14000>; /* MSM_TSPP_BAM_PHYS */
		reg-names = "MSM_TSIF0_PHYS",
			"MSM_TSIF1_PHYS",
			"MSM_TSPP_PHYS",
			"MSM_TSPP_BAM_PHYS";
		interrupts = <0 153 0>, /* TSIF_TSPP_IRQ */
			<0 151 0>, /* TSIF0_IRQ */
			<0 152 0>, /* TSIF1_IRQ */
			<0 154 0>; /* TSIF_BAM_IRQ */
		interrupt-names = "TSIF_TSPP_IRQ",
			"TSIF0_IRQ",
			"TSIF1_IRQ",
			"TSIF_BAM_IRQ";

		pinctrl-names = "disabled",
			"tsif0-mode1", "tsif0-mode2",
			"tsif1-mode1", "tsif1-mode2",
			"dual-tsif-mode1", "dual-tsif-mode2";

		pinctrl-0 = <>;				/* disabled */
		pinctrl-1 = <&tsif0_signals_active>;	/* tsif0-mode1 */
		pinctrl-2 = <&tsif0_signals_active
			&tsif0_sync_active>;		/* tsif0-mode2 */
		pinctrl-3 = <&tsif1_signals_active>;	/* tsif1-mode1 */
		pinctrl-4 = <&tsif1_signals_active
			&tsif1_sync_active>;		/* tsif1-mode2 */
		pinctrl-5 = <&tsif0_signals_active
			&tsif1_signals_active>;		/* dual-tsif-mode1 */
		pinctrl-6 = <&tsif0_signals_active
			&tsif0_sync_active
			&tsif1_signals_active
			&tsif1_sync_active>;		/* dual-tsif-mode2 */

		qcom,msm-bus,name = "tsif";
		qcom,msm-bus,num-cases = <2>;
		qcom,msm-bus,num-paths = <1>;
		qcom,msm-bus,vectors-KBps =
				<82 512 0 0>, /* No vote */
				<82 512 12288 24576>; /* Max. bandwidth, 2xTSIF, each max of 96Mbps */
	};
+219 −44
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@
 * Copyright (c) 2000 Nokia Research Center
 *                    Tampere, FINLAND
 *
 * Copyright (c) 2012-2014, 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 Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1
@@ -36,6 +38,8 @@
/* Common definitions */
/*--------------------------------------------------------------------------*/

#define DMX_EVENT_QUEUE_SIZE	500 /* number of events */

/*
 * DMX_MAX_FILTER_SIZE: Maximum length (in bytes) of a section/PES filter.
 */
@@ -59,15 +63,100 @@
/*
 * enum dmx_success: Success codes for the Demux Callback API.
 */

enum dmx_success {
	DMX_OK = 0, /* Received Ok */
	DMX_OK_PES_END, /* Received OK, data reached end of PES packet */
	DMX_OK_PCR, /* Received OK, data with new PCR/STC pair */
	DMX_OK_EOS, /* Received OK, reached End-of-Stream (EOS) */
	DMX_OK_MARKER, /* Received OK, reached a data Marker */
	DMX_LENGTH_ERROR, /* Incorrect length */
	DMX_OVERRUN_ERROR, /* Receiver ring buffer overrun */
	DMX_CRC_ERROR, /* Incorrect CRC */
	DMX_FRAME_ERROR, /* Frame alignment error */
	DMX_FIFO_ERROR, /* Receiver FIFO overrun */
  DMX_MISSED_ERROR /* Receiver missed packet */
	DMX_MISSED_ERROR, /* Receiver missed packet */
	DMX_OK_DECODER_BUF, /* Received OK, new ES data in decoder buffer */
	DMX_OK_IDX, /* Received OK, new index event */
	DMX_OK_SCRAMBLING_STATUS, /* Received OK, new scrambling status */
};


/*
 * struct dmx_data_ready: Parameters for event notification callback.
 * Event notification notifies demux device that data is written
 * and available in the device's output buffer or provides
 * notification on errors and other events. In the latter case
 * data_length is zero.
 */
struct dmx_data_ready {
	enum dmx_success status;

	/*
	 * data_length may be 0 in case of DMX_OK_PES_END or DMX_OK_EOS
	 * and in non-DMX_OK_XXX events. In DMX_OK_PES_END,
	 * data_length is for data coming after the end of PES.
	 */
	int data_length;

	union {
		struct {
			int start_gap;
			int actual_length;
			int disc_indicator_set;
			int pes_length_mismatch;
			u64 stc;
			u32 tei_counter;
			u32 cont_err_counter;
			u32 ts_packets_num;
		} pes_end;

		struct {
			u64 pcr;
			u64 stc;
			int disc_indicator_set;
		} pcr;

		struct {
			int handle;
			int cookie;
			u32 offset;
			u32 len;
			int pts_exists;
			u64 pts;
			int dts_exists;
			u64 dts;
			u32 tei_counter;
			u32 cont_err_counter;
			u32 ts_packets_num;
			u32 ts_dropped_bytes;
			u64 stc;
		} buf;

		struct {
			u64 id;
		} marker;

		struct dmx_index_event_info idx_event;
		struct dmx_scrambling_status_event_info scrambling_bits;
	};
};

/*
 * struct data_buffer: Parameters of buffer allocated by
 * demux device for input/output. Can be used to directly map the
 * demux-device buffer to HW output if HW supports it.
 */
struct data_buffer {
	/* dvb_ringbuffer managed by demux-device */
	const struct dvb_ringbuffer *ringbuff;


	/*
	 * Private handle returned by kernel demux when
	 * map_buffer is called in case external buffer
	 * is used. NULL if buffer is allocated internally.
	 */
	void *priv_handle;
};

/*--------------------------------------------------------------------------*/
@@ -83,10 +172,17 @@ enum dmx_success {
#define TS_DEMUX        8   /* in case TS_PACKET is set, send the TS to
			       the demux device, not to the dvr device */

struct dmx_ts_feed;
typedef int (*dmx_ts_data_ready_cb)(
		struct dmx_ts_feed *source,
		struct dmx_data_ready *dmx_data_ready);

struct dmx_ts_feed {
	int is_filtering; /* Set to non-zero when filtering in progress */
	struct dmx_demux *parent; /* Back-pointer */
	struct data_buffer buffer;
	void *priv; /* Pointer to private data of the API client */
	struct dmx_decoder_buffers *decoder_buffers;
	int (*set) (struct dmx_ts_feed *feed,
		    u16 pid,
		    int type,
@@ -95,6 +191,34 @@ struct dmx_ts_feed {
		    struct timespec timeout);
	int (*start_filtering)(struct dmx_ts_feed *feed);
	int (*stop_filtering)(struct dmx_ts_feed *feed);
	int (*set_video_codec)(struct dmx_ts_feed *feed,
				enum dmx_video_codec video_codec);
	int (*set_idx_params)(struct dmx_ts_feed *feed,
				struct dmx_indexing_params *idx_params);
	int (*get_decoder_buff_status)(
			struct dmx_ts_feed *feed,
			struct dmx_buffer_status *dmx_buffer_status);
	int (*reuse_decoder_buffer)(
			struct dmx_ts_feed *feed,
			int cookie);
	int (*data_ready_cb)(struct dmx_ts_feed *feed,
			dmx_ts_data_ready_cb callback);
	int (*notify_data_read)(struct dmx_ts_feed *feed,
			u32 bytes_num);
	int (*set_tsp_out_format)(struct dmx_ts_feed *feed,
				enum dmx_tsp_format_t tsp_format);
	int (*set_secure_mode)(struct dmx_ts_feed *feed,
				struct dmx_secure_mode *sec_mode);
	int (*set_cipher_ops)(struct dmx_ts_feed *feed,
				struct dmx_cipher_operations *cipher_ops);
	int (*oob_command)(struct dmx_ts_feed *feed,
			struct dmx_oob_command *cmd);
	int (*ts_insertion_init)(struct dmx_ts_feed *feed);
	int (*ts_insertion_terminate)(struct dmx_ts_feed *feed);
	int (*ts_insertion_insert_buffer)(struct dmx_ts_feed *feed,
			char *data, size_t size);
	int (*get_scrambling_bits)(struct dmx_ts_feed *feed, u8 *value);
	int (*flush_buffer)(struct dmx_ts_feed *feed, size_t length);
};

/*--------------------------------------------------------------------------*/
@@ -106,9 +230,15 @@ struct dmx_section_filter {
	u8 filter_mask [DMX_MAX_FILTER_SIZE];
	u8 filter_mode [DMX_MAX_FILTER_SIZE];
	struct dmx_section_feed* parent; /* Back-pointer */
	struct data_buffer buffer;
	void* priv; /* Pointer to private data of the API client */
};

struct dmx_section_feed;
typedef int (*dmx_section_data_ready_cb)(
		struct dmx_section_filter *source,
		struct dmx_data_ready *dmx_data_ready);

struct dmx_section_feed {
	int is_filtering; /* Set to non-zero when filtering in progress */
	struct dmx_demux* parent; /* Back-pointer */
@@ -121,16 +251,26 @@ struct dmx_section_feed {
	u8 secbuf_base[DMX_MAX_SECFEED_SIZE];
	u16 secbufp, seclen, tsfeedp;

	int (*set) (struct dmx_section_feed* feed,
		    u16 pid,
		    size_t circular_buffer_size,
		    int check_crc);
	int (*set)(struct dmx_section_feed *feed, u16 pid,
			size_t circular_buffer_size, int check_crc);
	int (*allocate_filter)(struct dmx_section_feed *feed,
				struct dmx_section_filter **filter);
	int (*release_filter)(struct dmx_section_feed *feed,
			       struct dmx_section_filter *filter);
	int (*start_filtering)(struct dmx_section_feed *feed);
	int (*stop_filtering)(struct dmx_section_feed *feed);
	int (*data_ready_cb)(struct dmx_section_feed *feed,
			dmx_section_data_ready_cb callback);
	int (*notify_data_read)(struct dmx_section_filter *filter,
			u32 bytes_num);
	int (*set_secure_mode)(struct dmx_section_feed *feed,
				struct dmx_secure_mode *sec_mode);
	int (*set_cipher_ops)(struct dmx_section_feed *feed,
				struct dmx_cipher_operations *cipher_ops);
	int (*oob_command)(struct dmx_section_feed *feed,
				struct dmx_oob_command *cmd);
	int (*get_scrambling_bits)(struct dmx_section_feed *feed, u8 *value);
	int (*flush_buffer)(struct dmx_section_feed *feed, size_t length);
};

/*--------------------------------------------------------------------------*/
@@ -151,6 +291,16 @@ typedef int (*dmx_section_cb) ( const u8 * buffer1,
				struct dmx_section_filter * source,
				enum dmx_success success);

typedef int (*dmx_ts_fullness) (
				struct dmx_ts_feed *source,
				int required_space,
				int wait);

typedef int (*dmx_section_fullness) (
				struct dmx_section_filter *source,
				int required_space,
				int wait);

/*--------------------------------------------------------------------------*/
/* DVB Front-End */
/*--------------------------------------------------------------------------*/
@@ -206,9 +356,15 @@ struct dmx_demux {
	u32 capabilities;            /* Bitfield of capability flags */
	struct dmx_frontend* frontend;    /* Front-end connected to the demux */
	void* priv;                  /* Pointer to private data of the API client */
	struct data_buffer dvr_input; /* DVR input buffer */
	int dvr_input_protected;
	struct dentry *debugfs_demux_dir; /* debugfs dir */

	int (*open)(struct dmx_demux *demux);
	int (*close)(struct dmx_demux *demux);
	int (*write) (struct dmx_demux* demux, const char __user *buf, size_t count);
	int (*write)(struct dmx_demux *demux,
			const char __user *buf,
			size_t count);
	int (*allocate_ts_feed)(struct dmx_demux *demux,
				 struct dmx_ts_feed **feed,
				 dmx_ts_cb callback);
@@ -234,8 +390,27 @@ struct dmx_demux {

	int (*set_source)(struct dmx_demux *demux, const dmx_source_t *src);

	int (*set_tsp_format)(struct dmx_demux *demux,
				enum dmx_tsp_format_t tsp_format);

	int (*set_playback_mode)(struct dmx_demux *demux,
				 enum dmx_playback_mode_t mode,
				 dmx_ts_fullness ts_fullness_callback,
				 dmx_section_fullness sec_fullness_callback);

	int (*write_cancel)(struct dmx_demux *demux);

	int (*get_stc)(struct dmx_demux *demux, unsigned int num,
			u64 *stc, unsigned int *base);

	int (*map_buffer)(struct dmx_demux *demux,
			struct dmx_buffer *dmx_buffer,
			void **priv_handle, void **mem);

	int (*unmap_buffer)(struct dmx_demux *demux,
			void *priv_handle);

	int (*get_tsp_size)(struct dmx_demux *demux);
};

#endif /* #ifndef __DEMUX_H */
+3872 −219

File changed.

Preview size limit exceeded, changes collapsed.

+135 −4
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@
 * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
 *                    for convergence integrated media GmbH
 *
 * Copyright (c) 2012-2014, 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 Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1
@@ -33,7 +35,7 @@
#include <linux/string.h>
#include <linux/mutex.h>
#include <linux/slab.h>

#include <linux/kthread.h>
#include <linux/dvb/dmx.h>

#include "dvbdev.h"
@@ -57,10 +59,87 @@ enum dmxdev_state {

struct dmxdev_feed {
	u16 pid;
	struct dmx_indexing_params idx_params;
	struct dmx_cipher_operations cipher_ops;
	struct dmx_ts_feed *ts;
	struct list_head next;
};

struct dmxdev_sec_feed {
	struct dmx_section_feed *feed;
	struct dmx_cipher_operations cipher_ops;
};

struct dmxdev_events_queue {
	/*
	 * indices used to manage events queue.
	 * read_index advanced when relevant data is read
	 * from the buffer.
	 * notified_index is the index from which next events
	 * are returned.
	 * read_index <= notified_index <= write_index
	 *
	 * If user reads the data without getting the respective
	 * event first, the read/notified indices are updated
	 * automatically to reflect the actual data that exist
	 * in the buffer.
	 */
	u32 read_index;
	u32 write_index;
	u32 notified_index;

	/* Bytes read by user without having respective event in the queue */
	u32 bytes_read_no_event;

	/* internal tracking of PES and recording events */
	u32 current_event_data_size;
	u32 current_event_start_offset;

	/* current setting of the events masking */
	struct dmx_events_mask event_mask;

	/*
	 * indicates if an event used for data-reading from demux
	 * filter is enabled or not. These are events on which
	 * user may wait for before calling read() on the demux filter.
	 */
	int data_read_event_masked;

	/*
	 * holds the current number of pending events in the
	 * events queue that are considered as a wake-up source
	 */
	u32 wakeup_events_counter;

	struct dmx_filter_event queue[DMX_EVENT_QUEUE_SIZE];
};

#define DMX_MIN_INSERTION_REPETITION_TIME	25 /* in msec */
struct ts_insertion_buffer {
	/* work scheduled for insertion of this buffer */
	struct delayed_work dwork;

	struct list_head next;

	/* buffer holding TS packets for insertion */
	char *buffer;

	/* buffer size */
	size_t size;

	/* buffer ID from user */
	u32 identifier;

	/* repetition time for the buffer insertion */
	u32 repetition_time;

	/* the recording filter to which this buffer belongs */
	struct dmxdev_filter *dmxdevfilter;

	/* indication whether insertion should be aborted */
	int abort;
};

struct dmxdev_filter {
	union {
		struct dmx_section_filter *sec;
@@ -69,7 +148,7 @@ struct dmxdev_filter {
	union {
		/* list of TS and PES feeds (struct dmxdev_feed) */
		struct list_head ts;
		struct dmx_section_feed *sec;
		struct dmxdev_sec_feed sec;
	} feed;

	union {
@@ -77,19 +156,37 @@ struct dmxdev_filter {
		struct dmx_pes_filter_params pes;
	} params;

	struct dmxdev_events_queue events;

	enum dmxdev_type type;
	enum dmxdev_state state;
	struct dmxdev *dev;
	struct dvb_ringbuffer buffer;
	void *priv_buff_handle;
	enum dmx_buffer_mode buffer_mode;

	struct mutex mutex;

	/* for recording output */
	enum dmx_tsp_format_t dmx_tsp_format;
	u32 rec_chunk_size;

	/* list of buffers used for insertion (struct ts_insertion_buffer) */
	struct list_head insertion_buffers;

	/* End-of-stream indication has been received */
	int eos_state;

	/* only for sections */
	struct timer_list timer;
	int todo;
	u8 secheader[3];
};

	struct dmx_secure_mode sec_mode;

	/* Decoder buffer(s) related */
	struct dmx_decoder_buffers decoder_buffers;
};

struct dmxdev {
	struct dvb_device *dvbdev;
@@ -100,18 +197,52 @@ struct dmxdev {

	int filternum;
	int capabilities;
#define DMXDEV_CAP_DUPLEX	0x01

	enum dmx_playback_mode_t playback_mode;
	dmx_source_t source;

	unsigned int exit:1;
#define DMXDEV_CAP_DUPLEX 1
	unsigned int dvr_in_exit:1;
	unsigned int dvr_processing_input:1;

	struct dmx_frontend *dvr_orig_fe;

	struct dvb_ringbuffer dvr_buffer;
	void *dvr_priv_buff_handle;
	enum dmx_buffer_mode dvr_buffer_mode;
	struct dmxdev_events_queue dvr_output_events;
	struct dmxdev_filter *dvr_feed;
	int dvr_feeds_count;

	struct dvb_ringbuffer dvr_input_buffer;
	enum dmx_buffer_mode dvr_input_buffer_mode;
	struct task_struct *dvr_input_thread;
	/* DVR commands (data feed / OOB command) queue */
	struct dvb_ringbuffer dvr_cmd_buffer;

#define DVR_BUFFER_SIZE (10*188*1024)

	struct mutex mutex;
	spinlock_t lock;
	spinlock_t dvr_in_lock;
};

enum dvr_cmd {
	DVR_DATA_FEED_CMD,
	DVR_OOB_CMD
};

struct dvr_command {
	enum dvr_cmd type;
	union {
		struct dmx_oob_command oobcmd;
		size_t data_feed_count;
	} cmd;
};

#define DVR_CMDS_BUFFER_SIZE (sizeof(struct dvr_command)*500)


int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *);
void dvb_dmxdev_release(struct dmxdev *dmxdev);
+2427 −322

File changed.

Preview size limit exceeded, changes collapsed.

Loading