Commit c0a80d5c authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

media: zoran: fix checkpatch --strict issues



Prepare for moving this driver to mainline by fixing the remaining
checkpatch issues.

Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 8847fb9b
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -92,9 +92,8 @@ struct videocodec *videocodec_attach(struct videocodec_master *master)

				h->attached += 1;
				return codec;
			} else {
				kfree(codec);
			}
			kfree(codec);
		}
		h = h->next;
	}
@@ -255,8 +254,8 @@ int videocodec_debugfs_show(struct seq_file *m)
	struct codec_list *h = codeclist_top;
	struct attached_list *a;

	seq_printf(m, "<S>lave or attached <M>aster name  type flags    magic    ");
	seq_printf(m, "(connected as)\n");
	seq_puts(m, "<S>lave or attached <M>aster name  type flags    magic    ");
	seq_puts(m, "(connected as)\n");

	while (h) {
		seq_printf(m, "S %32s %04x %08lx %08lx (TEMPLATE)\n",
+95 −95
Original line number Diff line number Diff line
@@ -12,42 +12,43 @@
/* general description */
/* =================== */

/* Should ease the (re-)usage of drivers supporting cards with (different)
   video codecs. The codecs register to this module their functionality,
   and the processors (masters) can attach to them if they fit.

   The codecs are typically have a "strong" binding to their master - so I
   don't think it makes sense to have a full blown interfacing as with e.g.
   i2c. If you have an other opinion, let's discuss & implement it :-)))

   Usage:

   The slave has just to setup the videocodec structure and use two functions:
   videocodec_register(codecdata);
   videocodec_unregister(codecdata);
   The best is just calling them at module (de-)initialisation.

   The master sets up the structure videocodec_master and calls:
   codecdata=videocodec_attach(master_codecdata);
   videocodec_detach(codecdata);

   The slave is called during attach/detach via functions setup previously
   during register. At that time, the master_data pointer is set up
   and the slave can access any io registers of the master device (in the case
   the slave is bound to it). Otherwise it doesn't need this functions and
   therfor they may not be initialized.

   The other functions are just for convenience, as they are for sure used by
   most/all of the codecs. The last ones may be omitted, too.

   See the structure declaration below for more information and which data has
   to be set up for the master and the slave.

   ----------------------------------------------------------------------------
   The master should have "knowledge" of the slave and vice versa.  So the data
   structures sent to/from slave via set_data/get_data set_image/get_image are
   device dependent and vary between MJPEG/MPEG/WAVELET/... devices. (!!!!)
   ----------------------------------------------------------------------------
/*
 * Should ease the (re-)usage of drivers supporting cards with (different)
 * video codecs. The codecs register to this module their functionality,
 * and the processors (masters) can attach to them if they fit.
 *
 * The codecs are typically have a "strong" binding to their master - so I
 * don't think it makes sense to have a full blown interfacing as with e.g.
 * i2c. If you have an other opinion, let's discuss & implement it :-)))
 *
 * Usage:
 *
 * The slave has just to setup the videocodec structure and use two functions:
 * videocodec_register(codecdata);
 * videocodec_unregister(codecdata);
 * The best is just calling them at module (de-)initialisation.
 *
 * The master sets up the structure videocodec_master and calls:
 * codecdata=videocodec_attach(master_codecdata);
 * videocodec_detach(codecdata);
 *
 * The slave is called during attach/detach via functions setup previously
 * during register. At that time, the master_data pointer is set up
 * and the slave can access any io registers of the master device (in the case
 * the slave is bound to it). Otherwise it doesn't need this functions and
 * therefor they may not be initialized.
 *
 * The other functions are just for convenience, as they are for sure used by
 * most/all of the codecs. The last ones may be omitted, too.
 *
 * See the structure declaration below for more information and which data has
 * to be set up for the master and the slave.
 *
 * ----------------------------------------------------------------------------
 * The master should have "knowledge" of the slave and vice versa.  So the data
 * structures sent to/from slave via set_data/get_data set_image/get_image are
 * device dependent and vary between MJPEG/MPEG/WAVELET/... devices. (!!!!)
 * ----------------------------------------------------------------------------
 */

/* ========================================== */
@@ -55,45 +56,45 @@
/* ========================================== */

/*
   ==== master setup ====
   name -> name of the device structure for reference and debugging
   master_data ->  data ref. for the master (e.g. the zr36055,57,67)
   readreg -> ref. to read-fn from register (setup by master, used by slave)
   writereg -> ref. to write-fn to register (setup by master, used by slave)
	       this two functions do the lowlevel I/O job

   ==== slave functionality setup ====
   slave_data -> data ref. for the slave (e.g. the zr36050,60)
   check -> fn-ref. checks availability of an device, returns -EIO on failure or
	    the type on success
	    this makes espcecially sense if a driver module supports more than
	    one codec which may be quite similar to access, nevertheless it
	    is good for a first functionality check

   -- main functions you always need for compression/decompression --

   set_mode -> this fn-ref. resets the entire codec, and sets up the mode
	       with the last defined norm/size (or device default if not
	       available) - it returns 0 if the mode is possible
   set_size -> this fn-ref. sets the norm and image size for
	       compression/decompression (returns 0 on success)
	       the norm param is defined in videodev2.h (V4L2_STD_*)

   additional setup may be available, too - but the codec should work with
   some default values even without this

   set_data -> sets device-specific data (tables, quality etc.)
   get_data -> query device-specific data (tables, quality etc.)

   if the device delivers interrupts, they may be setup/handled here
   setup_interrupt -> codec irq setup (not needed for 36050/60)
   handle_interrupt -> codec irq handling (not needed for 36050/60)

   if the device delivers pictures, they may be handled here
   put_image -> puts image data to the codec (not needed for 36050/60)
   get_image -> gets image data from the codec (not needed for 36050/60)
		the calls include frame numbers and flags (even/odd/...)
		if needed and a flag which allows blocking until its ready
 * ==== master setup ====
 * name -> name of the device structure for reference and debugging
 * master_data ->  data ref. for the master (e.g. the zr36055,57,67)
 * readreg -> ref. to read-fn from register (setup by master, used by slave)
 * writereg -> ref. to write-fn to register (setup by master, used by slave)
 *	       this two functions do the lowlevel I/O job
 *
 * ==== slave functionality setup ====
 * slave_data -> data ref. for the slave (e.g. the zr36050,60)
 * check -> fn-ref. checks availability of an device, returns -EIO on failure or
 *	    the type on success
 *	    this makes espcecially sense if a driver module supports more than
 *	    one codec which may be quite similar to access, nevertheless it
 *	    is good for a first functionality check
 *
 * -- main functions you always need for compression/decompression --
 *
 * set_mode -> this fn-ref. resets the entire codec, and sets up the mode
 *	       with the last defined norm/size (or device default if not
 *	       available) - it returns 0 if the mode is possible
 * set_size -> this fn-ref. sets the norm and image size for
 *	       compression/decompression (returns 0 on success)
 *	       the norm param is defined in videodev2.h (V4L2_STD_*)
 *
 * additional setup may be available, too - but the codec should work with
 * some default values even without this
 *
 * set_data -> sets device-specific data (tables, quality etc.)
 * get_data -> query device-specific data (tables, quality etc.)
 *
 * if the device delivers interrupts, they may be setup/handled here
 * setup_interrupt -> codec irq setup (not needed for 36050/60)
 * handle_interrupt -> codec irq handling (not needed for 36050/60)

 * if the device delivers pictures, they may be handled here
 * put_image -> puts image data to the codec (not needed for 36050/60)
 * get_image -> gets image data from the codec (not needed for 36050/60)
 *		the calls include frame numbers and flags (even/odd/...)
 *		if needed and a flag which allows blocking until its ready
 */

/* ============== */
@@ -101,19 +102,18 @@
/* ============== */

/*
   Currently there is only a information display planned, as the layer
   is not visible for the user space at all.

   Information is available via procfs. The current entry is "/proc/videocodecs"
   but it makes sense to "hide" it in the /proc/video tree of v4l(2) --TODO--.

A example for such an output is:

<S>lave or attached <M>aster name  type flags    magic    (connected as)
S                          zr36050 0002 0000d001 00000000 (TEMPLATE)
M                       zr36055[0] 0001 0000c001 00000000 (zr36050[0])
M                       zr36055[1] 0001 0000c001 00000000 (zr36050[1])

 * Currently there is only a information display planned, as the layer
 * is not visible for the user space at all.
 *
 * Information is available via procfs. The current entry is "/proc/videocodecs"
 * but it makes sense to "hide" it in the /proc/video tree of v4l(2) --TODO--.
 *
 * A example for such an output is:
 *
 * <S>lave or attached <M>aster name  type flags    magic    (connected as)
 * S                          zr36050 0002 0000d001 00000000 (TEMPLATE)
 * M                       zr36055[0] 0001 0000c001 00000000 (zr36050[0])
 * M                       zr36055[1] 0001 0000c001 00000000 (zr36050[1])
 */

/* =============================================== */
@@ -293,15 +293,15 @@ struct videocodec_master {
// * master structure needs to be kmalloc'ed before calling attach
//   and free'd after calling detach
// * returns pointer on success, NULL on failure
extern struct videocodec *videocodec_attach(struct videocodec_master *);
struct videocodec *videocodec_attach(struct videocodec_master *master);
// * 0 on success, <0 (errno) on failure
extern int videocodec_detach(struct videocodec *);
int videocodec_detach(struct videocodec *codec);

/* register and unregister commands for the slaves */
// * 0 on success, <0 (errno) on failure
extern int videocodec_register(const struct videocodec *);
int videocodec_register(const struct videocodec *codec);
// * 0 on success, <0 (errno) on failure
extern int videocodec_unregister(const struct videocodec *);
int videocodec_unregister(const struct videocodec *codec);

/* the other calls are directly done via the videocodec structure! */

+19 −11
Original line number Diff line number Diff line
@@ -140,11 +140,16 @@ struct zoran_v4l_settings {

/* jpg-capture/-playback settings */
struct zoran_jpg_settings {
	int decimation;		/* this bit is used to set everything to default */
	int hor_dcm, ver_dcm, tmp_dcm;	/* capture decimation settings (tmp_dcm=1 means both fields) */
	int field_per_buff, odd_even;	/* field-settings (odd_even=1 (+tmp_dcm=1) means top-field-first) */
	int img_x, img_y, img_width, img_height;	/* crop settings (subframe capture) */
	struct v4l2_jpegcompression jpg_comp;	/* JPEG-specific capture settings */
	/* this bit is used to set everything to default */
	int decimation;
	/* capture decimation settings (tmp_dcm=1 means both fields) */
	int hor_dcm, ver_dcm, tmp_dcm;
	/* field-settings (odd_even=1 (+tmp_dcm=1) means top-field-first) */
	int field_per_buff, odd_even;
	/* crop settings (subframe capture) */
	int img_x, img_y, img_width, img_height;
	/* JPEG-specific capture settings */
	struct v4l2_jpegcompression jpg_comp;
};

struct zoran;
@@ -248,7 +253,8 @@ struct zoran {
	unsigned long vbseq;

	/* zr36057's code buffer table */
	__le32 *stat_com;		/* stat_com[i] is indexed by dma_head/tail & BUZ_MASK_STAT_COM */
	/* stat_com[i] is indexed by dma_head/tail & BUZ_MASK_STAT_COM */
	__le32 *stat_com;

	/* Additional stuff for testing */
	unsigned int ghost_int;
@@ -292,14 +298,16 @@ static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev)
	return container_of(v4l2_dev, struct zoran, v4l2_dev);
}

/* There was something called _ALPHA_BUZ that used the PCI address instead of
 * the kernel iomapped address for btread/btwrite.  */
/*
 * There was something called _ALPHA_BUZ that used the PCI address instead of
 * the kernel iomapped address for btread/btwrite.
 */
#define btwrite(dat, adr)    writel((dat), zr->zr36057_mem + (adr))
#define btread(adr)         readl(zr->zr36057_mem + (adr))

#define btand(dat, adr)      btwrite((dat) & btread(adr), adr)
#define btor(dat, adr)       btwrite((dat) | btread(adr), adr)
#define btaor(dat, mask, adr) btwrite((dat) | ((mask) & btread(adr)), adr)
#define btand(dat, adr)      btwrite((dat) & btread(adr), (adr))
#define btor(dat, adr)       btwrite((dat) | btread(adr), (adr))
#define btaor(dat, mask, adr) btwrite((dat) | ((mask) & btread(adr)), (adr))

#endif

+26 −23
Original line number Diff line number Diff line
@@ -172,8 +172,6 @@ void zr36016_write(struct videocodec *codec, u16 reg, u32 val)

static void dc10_init(struct zoran *zr)
{
	pci_dbg(zr->pci_dev, "%s\n", __func__);

	/* Pixel clock selection */
	GPIO(zr, 4, 0);
	GPIO(zr, 5, 1);
@@ -183,13 +181,10 @@ static void dc10_init(struct zoran *zr)

static void dc10plus_init(struct zoran *zr)
{
	pci_dbg(zr->pci_dev, "%s\n", __func__);
}

static void buz_init(struct zoran *zr)
{
	pci_dbg(zr->pci_dev, "%s\n", __func__);

	/* some stuff from Iomega */
	pci_write_config_dword(zr->pci_dev, 0xfc, 0x90680f15);
	pci_write_config_dword(zr->pci_dev, 0x0c, 0x00012020);
@@ -198,8 +193,6 @@ static void buz_init(struct zoran *zr)

static void lml33_init(struct zoran *zr)
{
	pci_dbg(zr->pci_dev, "%s\n", __func__);

	GPIO(zr, 2, 1);		// Set Composite input/output
}

@@ -334,10 +327,6 @@ static void videocodec_exit(struct zoran *zr)
		codec_exit(zr, zr->card.video_vfe);
}

// struct tvnorm {
//      u16 wt, wa, h_start, h_sync_start, ht, ha, v_start;
// };

static const struct tvnorm f50sqpixel = { 944, 768, 83, 880, 625, 576, 16 };
static const struct tvnorm f60sqpixel = { 780, 640, 51, 716, 525, 480, 12 };
static const struct tvnorm f50ccir601 = { 864, 720, 75, 804, 625, 576, 18 };
@@ -619,7 +608,10 @@ static struct card_info zoran_cards[NUM_CARDS] = {
	}, {
		.type = AVS6EYES,
		.name = "6-Eyes",
/* AverMedia chose not to brand the 6-Eyes. Thus it can't be autodetected, and requires card=x. */
		/*
		 * AverMedia chose not to brand the 6-Eyes. Thus it can't be
		 * autodetected, and requires card=x.
		 */
		.i2c_decoder = "ks0127",
		.addrs_decoder = ks0127_addrs,
		.i2c_encoder = "bt866",
@@ -764,7 +756,9 @@ int zoran_check_jpg_settings(struct zoran *zr,
	case 4:

		if (zr->card.type == DC10_NEW) {
			pci_dbg(zr->pci_dev, "%s - HDec by 4 is not supported on the DC10\n", __func__);
			pci_dbg(zr->pci_dev,
				"%s - HDec by 4 is not supported on the DC10\n",
				__func__);
			err0++;
			break;
		}
@@ -1019,7 +1013,9 @@ static int zr36057_init(struct zoran *zr)
		zr->timing = zr->card.tvn[ZR_NORM_SECAM];
	}
	if (!zr->timing) {
		pci_warn(zr->pci_dev, "%s - default TV standard not supported by hardware. PAL will be used.\n", __func__);
		pci_warn(zr->pci_dev,
			 "%s - default TV standard not supported by hardware. PAL will be used.\n",
			 __func__);
		zr->norm = V4L2_STD_PAL;
		zr->timing = zr->card.tvn[ZR_NORM_PAL];
	}
@@ -1038,9 +1034,9 @@ static int zr36057_init(struct zoran *zr)
	zr->stat_com = dma_alloc_coherent(&zr->pci_dev->dev,
					  BUZ_NUM_STAT_COM * sizeof(u32),
					  &zr->p_sc, GFP_KERNEL);
	if (!zr->stat_com) {
	if (!zr->stat_com)
		return -ENOMEM;
	}

	for (j = 0; j < BUZ_NUM_STAT_COM; j++)
		zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to zr36057 */

@@ -1066,9 +1062,11 @@ static int zr36057_init(struct zoran *zr)
	return 0;

exit_statcomb:
	dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32) * 2, zr->stat_comb, zr->p_scb);
	dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32) * 2,
			  zr->stat_comb, zr->p_scb);
exit_statcom:
	dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), zr->stat_com, zr->p_sc);
	dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32),
			  zr->stat_com, zr->p_sc);
	return err;
}

@@ -1099,8 +1097,10 @@ static void zoran_remove(struct pci_dev *pdev)
	btwrite(0, ZR36057_SPGPPCR);
	pci_free_irq(zr->pci_dev, 0, zr);
	/* unmap and free memory */
	dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32), zr->stat_com, zr->p_sc);
	dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32) * 2, zr->stat_comb, zr->p_scb);
	dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32),
			  zr->stat_com, zr->p_sc);
	dma_free_coherent(&zr->pci_dev->dev, BUZ_NUM_STAT_COM * sizeof(u32) * 2,
			  zr->stat_comb, zr->p_scb);
	pci_release_regions(pdev);
	pci_disable_device(zr->pci_dev);
	zoran_exit_video_devices(zr);
@@ -1299,7 +1299,8 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
			pci_err(pdev, "Unknown card, try specifying card=X module parameter\n");
			goto zr_unreg;
		}
		pci_info(zr->pci_dev, "%s() - card %s detected\n", __func__, zoran_cards[card_num].name);
		pci_info(zr->pci_dev, "%s() - card %s detected\n", __func__,
			 zoran_cards[card_num].name);
	} else {
		card_num = card[nr];
		if (card_num >= NUM_CARDS || card_num < 0) {
@@ -1324,7 +1325,8 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
	if (err)
		goto zr_unreg;

	zr->zr36057_mem = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
	zr->zr36057_mem = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0),
				       pci_resource_len(pdev, 0));
	if (!zr->zr36057_mem) {
		pci_err(pdev, "%s() - ioremap failed\n", __func__);
		goto zr_pci_release;
@@ -1348,7 +1350,8 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
			     &latency);
	need_latency = zr->revision > 1 ? 32 : 48;
	if (latency != need_latency) {
		pci_info(zr->pci_dev, "Changing PCI latency from %d to %d\n", latency, need_latency);
		pci_info(zr->pci_dev, "Changing PCI latency from %d to %d\n",
			 latency, need_latency);
		pci_write_config_byte(zr->pci_dev, PCI_LATENCY_TIMER, need_latency);
	}

+4 −5
Original line number Diff line number Diff line
@@ -19,11 +19,10 @@ extern int zr36067_debug;

extern const struct video_device zoran_template;

extern int zoran_check_jpg_settings(struct zoran *zr,
				    struct zoran_jpg_settings *settings,
				    int try);
extern void zoran_open_init_params(struct zoran *zr);
extern void zoran_vdev_release(struct video_device *vdev);
int zoran_check_jpg_settings(struct zoran *zr,
			     struct zoran_jpg_settings *settings, int try);
void zoran_open_init_params(struct zoran *zr);
void zoran_vdev_release(struct video_device *vdev);

void zr36016_write(struct videocodec *codec, u16 reg, u32 val);

Loading