Commit 83f89a8b authored by Corentin Labbe's avatar Corentin Labbe Committed by Mauro Carvalho Chehab
Browse files

media: zoran: convert to vb2



This is it! the ultimate last step, the vb2 conversion.

Signed-off-by: default avatarCorentin Labbe <clabbe@baylibre.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 8cb356d4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
config VIDEO_ZORAN
	tristate "Zoran ZR36057/36067 Video For Linux (Deprecated)"
	depends on PCI && I2C_ALGOBIT && VIDEO_V4L2 && VIRT_TO_BUS
	depends on PCI && I2C_ALGOBIT && VIDEO_V4L2
	depends on !ALPHA
	select VIDEOBUF2_DMA_CONTIG
	help
+1 −82
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@

#include <media/v4l2-device.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-fh.h>
#include <media/videobuf2-core.h>
#include <media/videobuf2-v4l2.h>
#include <media/videobuf2-dma-contig.h>
@@ -29,13 +28,6 @@
#define ZR_NORM_NTSC 1
#define ZR_NORM_SECAM 2

struct zoran_sync {
	unsigned long frame;	/* number of buffer that has been free'd */
	unsigned long length;	/* number of code bytes in buffer (capture only) */
	unsigned long seq;	/* frame sequence number */
	u64 ts;			/* timestamp */
};

struct zr_buffer {
	/* common v4l buffer stuff -- must be first */
	struct vb2_v4l2_buffer          vbuf;
@@ -111,18 +103,10 @@ enum zoran_codec_mode {
	BUZ_MODE_STILL_DECOMPRESS	/* still frame conversion */
};

enum zoran_buffer_state {
	BUZ_STATE_USER,		/* buffer is owned by application */
	BUZ_STATE_PEND,		/* buffer is queued in pend[] ready to feed to I/O */
	BUZ_STATE_DMA,		/* buffer is queued in dma[] for I/O */
	BUZ_STATE_DONE		/* buffer is ready to return to application */
};

enum zoran_map_mode {
	ZORAN_MAP_MODE_NONE,
	ZORAN_MAP_MODE_RAW,
	ZORAN_MAP_MODE_JPG_REC,
#define ZORAN_MAP_MODE_JPG ZORAN_MAP_MODE_JPG_REC
	ZORAN_MAP_MODE_JPG_PLAY,
};

@@ -174,45 +158,6 @@ struct zoran_jpg_settings {
	struct v4l2_jpegcompression jpg_comp;	/* JPEG-specific capture settings */
};

struct zoran_fh;

struct zoran_mapping {
	struct zoran_fh *fh;
	atomic_t count;
};

struct zoran_buffer {
	struct zoran_mapping *map;
	enum zoran_buffer_state state;	/* state: unused/pending/dma/done */
	struct zoran_sync bs;		/* DONE: info to return to application */
	union {
		struct {
			__le32 *frag_tab;	/* addresses of frag table */
			u32 frag_tab_bus;	/* same value cached to save time in ISR */
		} jpg;
		struct {
			char *fbuffer;		/* virtual address of frame buffer */
			unsigned long fbuffer_phys;/* physical address of frame buffer */
			unsigned long fbuffer_bus;/* bus address of frame buffer */
		} v4l;
	};
};

enum zoran_lock_activity {
	ZORAN_FREE,		/* free for use */
	ZORAN_ACTIVE,		/* active but unlocked */
	ZORAN_LOCKED,		/* locked */
};

/* buffer collections */
struct zoran_buffer_col {
	enum zoran_lock_activity active;	/* feature currently in use? */
	unsigned int num_buffers;
	struct zoran_buffer buffer[MAX_FRAME];	/* buffers */
	u8 allocated;		/* Flag if buffers are allocated */
	u8 need_contiguous;	/* Flag if contiguous buffers are needed */
	/* only applies to jpg buffers, raw buffers are always contiguous */
};

struct zoran;

@@ -220,10 +165,6 @@ struct zoran;
struct zoran_fh {
	struct v4l2_fh fh;
	struct zoran *zr;

	enum zoran_map_mode map_mode;		/* Flag which bufferset will map by next mmap() */

	struct zoran_buffer_col buffers;	/* buffers' info */
};

struct card_info {
@@ -281,7 +222,6 @@ struct zoran {
	struct mutex lock;	/* file ops serialize lock */

	u8 initialized;		/* flag if zoran has been correctly initialized */
	int user;		/* number of current users */
	struct card_info card;
	const struct tvnorm *timing;

@@ -300,28 +240,12 @@ struct zoran {
	/* Current buffer params */
	unsigned int buffer_size;

	wait_queue_head_t v4l_capq;

	int v4l_memgrab_active;	/* Memory grab is activated */

	int v4l_grab_frame;	/* Frame number being currently grabbed */
#define NO_GRAB_ACTIVE (-1)
	unsigned long v4l_grab_seq;	/* Number of frames grabbed */
	struct zoran_v4l_settings v4l_settings;	/* structure with a lot of things to play with */

	/* V4L grab queue of frames pending */
	unsigned long v4l_pend_head;
	unsigned long v4l_pend_tail;
	unsigned long v4l_sync_tail;
	int v4l_pend[V4L_MAX_FRAME];
	struct zoran_buffer_col v4l_buffers;	/* V4L buffers' info */

	/* Buz MJPEG parameters */
	enum zoran_codec_mode codec_mode;	/* status of codec */
	struct zoran_jpg_settings jpg_settings;	/* structure with a lot of things to play with */

	wait_queue_head_t jpg_capq;	/* wait here for grab to finish */

	/* grab queue counts/indices, mask with BUZ_MASK_STAT_COM before using as index */
	/* (dma_head - dma_tail) is number active in DMA, must be <= BUZ_NUM_STAT_COM */
	/* (value & BUZ_MASK_STAT_COM) corresponds to index in stat_com table */
@@ -338,13 +262,8 @@ struct zoran {
	/* zr36057's code buffer table */
	__le32 *stat_com;		/* stat_com[i] is indexed by dma_head/tail & BUZ_MASK_STAT_COM */

	/* (value & BUZ_MASK_FRAME) corresponds to index in pend[] queue */
	int jpg_pend[BUZ_MAX_FRAME];

	/* array indexed by frame number */
	struct zoran_buffer_col jpg_buffers;	/* MJPEG buffers' info */

	/* Additional stuff for testing */
	unsigned int ghost_int;
	int jpeg_error;
	int intr_counter_GIRQ1;
	int intr_counter_GIRQ0;
+4 −41
Original line number Diff line number Diff line
@@ -10,25 +10,17 @@
 */

#include <linux/delay.h>

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>

#include <linux/i2c.h>
#include <linux/i2c-algo-bit.h>
#include <linux/videodev2.h>
#include <linux/spinlock.h>
#include <linux/sem.h>
#include <linux/kmod.h>
#include <linux/wait.h>

#include <linux/pci.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <linux/io.h>
#include <media/v4l2-common.h>
#include <media/i2c/bt819.h>
@@ -814,29 +806,12 @@ void zoran_open_init_params(struct zoran *zr)
{
	int i;

	zr->v4l_memgrab_active = 0;
	zr->v4l_grab_frame = NO_GRAB_ACTIVE;
	zr->v4l_grab_seq = 0;
	zr->v4l_settings.width = 192;
	zr->v4l_settings.height = 144;
	zr->v4l_settings.format = &zoran_formats[7];	/* YUY2 - YUV-4:2:2 packed */
	zr->v4l_settings.bytesperline =
	    zr->v4l_settings.width *
	zr->v4l_settings.bytesperline = zr->v4l_settings.width *
		((zr->v4l_settings.format->depth + 7) / 8);

	/* DMA ring stuff for V4L */
	zr->v4l_pend_tail = 0;
	zr->v4l_pend_head = 0;
	zr->v4l_sync_tail = 0;
	zr->v4l_buffers.active = ZORAN_FREE;
	for (i = 0; i < VIDEO_MAX_FRAME; i++)
		zr->v4l_buffers.buffer[i].state = BUZ_STATE_USER;	/* nothing going on */
	zr->v4l_buffers.allocated = 0;

	for (i = 0; i < BUZ_MAX_FRAME; i++)
		zr->jpg_buffers.buffer[i].state = BUZ_STATE_USER;	/* nothing going on */
	zr->jpg_buffers.active = ZORAN_FREE;
	zr->jpg_buffers.allocated = 0;
	/* Set necessary params and call zoran_check_jpg_settings to set the defaults */
	zr->jpg_settings.decimation = 1;
	zr->jpg_settings.jpg_comp.quality = 50;	/* default compression factor 8 */
@@ -868,14 +843,6 @@ static int zr36057_init(struct zoran *zr)

	pci_info(zr->pci_dev, "initializing card[%d]\n", zr->id);

	/* default setup of all parameters which will persist between opens */
	zr->user = 0;

	init_waitqueue_head(&zr->v4l_capq);
	init_waitqueue_head(&zr->jpg_capq);
	zr->jpg_buffers.allocated = 0;
	zr->v4l_buffers.allocated = 0;

	/* Avoid nonsense settings from user for default input/norm */
	if (default_norm < 0 || default_norm > 2)
		default_norm = 0;
@@ -951,8 +918,6 @@ static int zr36057_init(struct zoran *zr)
	video_set_drvdata(zr->video_dev, zr);

	zoran_init_hardware(zr);
	if (zr36067_debug > 2)
		detect_guest_activity(zr);
	if (!pass_through) {
		decoder_call(zr, video, s_stream, 0);
		encoder_call(zr, video, s_routing, 2, 0, 0);
@@ -1279,10 +1244,8 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
	}

	/* take care of Natoma chipset and a revision 1 zr36057 */
	if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) {
		zr->jpg_buffers.need_contiguous = 1;
	if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1)
		pci_info(zr->pci_dev, "ZR36057/Natoma bug, max. buffer size is 128K\n");
	}

	if (zr36057_init(zr) < 0)
		goto zr_detach_vfe;
+85 −403

File changed.

Preview size limit exceeded, changes collapsed.

+46 −1407

File changed.

Preview size limit exceeded, changes collapsed.