2020-09-25 21:30:15 +03:00
/* SPDX-License-Identifier: GPL-2.0-or-later */
2020-09-25 21:30:11 +03:00
/*
* zoran - Iomega Buz driver
*
* Copyright ( C ) 1999 Rainer Johanni < Rainer @ Johanni . de >
*
* based on
*
* zoran .0 .0 .3 Copyright ( C ) 1998 Dave Perks < dperks @ ibm . net >
*
* and
*
* bttv - Bt848 frame grabber driver
* Copyright ( C ) 1996 , 97 , 98 Ralph Metzler ( rjkm @ thp . uni - koeln . de )
* & Marcus Metzler ( mocm @ thp . uni - koeln . de )
*/
# ifndef _BUZ_H_
# define _BUZ_H_
2021-12-14 19:16:22 +03:00
# include <linux/debugfs.h>
2022-05-06 08:28:00 +03:00
# include <linux/pci.h>
2022-05-06 08:28:19 +03:00
# include <linux/i2c-algo-bit.h>
2020-09-25 21:30:11 +03:00
# include <media/v4l2-device.h>
# include <media/v4l2-ctrls.h>
2020-09-25 21:30:46 +03:00
# include <media/videobuf2-core.h>
# include <media/videobuf2-v4l2.h>
# include <media/videobuf2-dma-contig.h>
2020-09-25 21:30:11 +03:00
2020-09-25 21:30:34 +03:00
# define ZR_NORM_PAL 0
# define ZR_NORM_NTSC 1
# define ZR_NORM_SECAM 2
2020-09-25 21:30:46 +03:00
struct zr_buffer {
/* common v4l buffer stuff -- must be first */
struct vb2_v4l2_buffer vbuf ;
struct list_head queue ;
} ;
static inline struct zr_buffer * vb2_to_zr_buffer ( struct vb2_buffer * vb )
{
struct vb2_v4l2_buffer * vbuf = to_vb2_v4l2_buffer ( vb ) ;
return container_of ( vbuf , struct zr_buffer , vbuf ) ;
}
2020-09-25 21:30:11 +03:00
# define ZORAN_NAME "ZORAN" /* name of the device */
# define ZR_DEVNAME(zr) ((zr)->name)
media: zoran: fix mixed case on vars
Use this small script to replace CamelCase and wrong case
on vars:
<script>
FILES=$(find "$1" -type f|grep -e '.c$' -e '.h$')
CAMEL_VARS=$(cat tags|perl -ne 'print "$1\n" if (m/^(\w*[A-Z]\w*[a-z]\w*)\s/)')
for i in $CAMEL_VARS; do
new=$(perl -e '
my $s = $ARGV[0];
$s =~ s{([^a-zA-Z]?)([A-Z]*)([A-Z])([a-z]?)}{
my $fc = pos($s)==0;
my ($p0,$p1,$p2,$p3) = ($1,lc$2,lc$3,$4);
my $t = $p0 || $fc ? $p0 : '_';
$t .= $p3 ? $p1 ? "${p1}_$p2$p3" : "$p2$p3" : "$p1$p2";
$t;
}ge;
print $s;' "$i")
for j in $FILES; do
sed -E "s,\b$i\b,$new,g" -i $j
done
done
for i in $(git grep "#define zr" drivers/staging/media/zoran/*.[ch]|perl -ne 'print "$1\n" if (m/#define\s+(zr\S+)/)'); do j=$(echo $i|tr [a-z] [A-Z]); sed "s,\b$i\b,$j,g" -i drivers/staging/media/zoran/*.[ch]; done
</script>
This should solve almost all warnings reported by checkpatch.pl
in strict mode.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-10-01 12:15:47 +03:00
# define BUZ_MAX_WIDTH (zr->timing->wa)
# define BUZ_MAX_HEIGHT (zr->timing->ha)
2020-09-25 21:30:11 +03:00
# define BUZ_MIN_WIDTH 32 /* never display less than 32 pixels */
# define BUZ_MIN_HEIGHT 24 /* never display less than 24 rows */
# define BUZ_NUM_STAT_COM 4
# define BUZ_MASK_STAT_COM 3
# define BUZ_MAX_INPUT 16
# include "zr36057.h"
enum card_type {
UNKNOWN = - 1 ,
/* Pinnacle/Miro */
2020-10-01 12:00:29 +03:00
DC10_OLD , /* DC30 like */
DC10_NEW , /* DC10_PLUS like */
DC10_PLUS ,
2020-09-25 21:30:11 +03:00
DC30 ,
2020-10-01 12:00:29 +03:00
DC30_PLUS ,
2020-09-25 21:30:11 +03:00
/* Linux Media Labs */
LML33 ,
LML33R10 ,
/* Iomega */
BUZ ,
/* AverMedia */
AVS6EYES ,
/* total number of cards */
NUM_CARDS
} ;
enum zoran_codec_mode {
BUZ_MODE_IDLE , /* nothing going on */
BUZ_MODE_MOTION_COMPRESS , /* grabbing frames */
BUZ_MODE_MOTION_DECOMPRESS , /* playing frames */
BUZ_MODE_STILL_COMPRESS , /* still frame conversion */
BUZ_MODE_STILL_DECOMPRESS /* still frame conversion */
} ;
enum zoran_map_mode {
2020-09-25 21:30:46 +03:00
ZORAN_MAP_MODE_NONE ,
2020-09-25 21:30:11 +03:00
ZORAN_MAP_MODE_RAW ,
ZORAN_MAP_MODE_JPG_REC ,
ZORAN_MAP_MODE_JPG_PLAY ,
} ;
enum gpio_type {
ZR_GPIO_JPEG_SLEEP = 0 ,
ZR_GPIO_JPEG_RESET ,
ZR_GPIO_JPEG_FRAME ,
ZR_GPIO_VID_DIR ,
ZR_GPIO_VID_EN ,
ZR_GPIO_VID_RESET ,
ZR_GPIO_CLK_SEL1 ,
ZR_GPIO_CLK_SEL2 ,
ZR_GPIO_MAX ,
} ;
enum gpcs_type {
GPCS_JPEG_RESET = 0 ,
GPCS_JPEG_START ,
GPCS_MAX ,
} ;
struct zoran_format {
char * name ;
__u32 fourcc ;
int colorspace ;
int depth ;
__u32 flags ;
__u32 vfespfr ;
} ;
2020-09-25 21:30:15 +03:00
2020-09-25 21:30:11 +03:00
/* flags */
2020-09-25 21:30:15 +03:00
# define ZORAN_FORMAT_COMPRESSED BIT(0)
# define ZORAN_FORMAT_OVERLAY BIT(1)
# define ZORAN_FORMAT_CAPTURE BIT(2)
# define ZORAN_FORMAT_PLAYBACK BIT(3)
2020-09-25 21:30:11 +03:00
/* v4l-capture settings */
struct zoran_v4l_settings {
int width , height , bytesperline ; /* capture size */
const struct zoran_format * format ; /* capture format */
} ;
/* jpg-capture/-playback settings */
struct zoran_jpg_settings {
2022-08-10 14:54:42 +03:00
/* 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 ;
2020-09-25 21:30:11 +03:00
} ;
struct zoran ;
/* zoran_fh contains per-open() settings */
struct zoran_fh {
struct v4l2_fh fh ;
struct zoran * zr ;
} ;
struct card_info {
enum card_type type ;
char name [ 32 ] ;
const char * i2c_decoder ; /* i2c decoder device */
const unsigned short * addrs_decoder ;
const char * i2c_encoder ; /* i2c encoder device */
const unsigned short * addrs_encoder ;
u16 video_vfe , video_codec ; /* videocodec types */
u16 audio_chip ; /* audio type */
int inputs ; /* number of video inputs */
struct input {
int muxsel ;
char name [ 32 ] ;
} input [ BUZ_MAX_INPUT ] ;
v4l2_std_id norms ;
2020-09-25 21:30:43 +03:00
const struct tvnorm * tvn [ 3 ] ; /* supported TV norms */
2020-09-25 21:30:11 +03:00
u32 jpeg_int ; /* JPEG interrupt */
u32 vsync_int ; /* VSYNC interrupt */
s8 gpio [ ZR_GPIO_MAX ] ;
u8 gpcs [ GPCS_MAX ] ;
struct vfe_polarity vfe_pol ;
u8 gpio_pol [ ZR_GPIO_MAX ] ;
/* is the /GWS line connected? */
u8 gws_not_connected ;
/* avs6eyes mux setting */
u8 input_mux ;
2020-09-25 21:30:15 +03:00
void ( * init ) ( struct zoran * zr ) ;
2020-09-25 21:30:11 +03:00
} ;
struct zoran {
struct v4l2_device v4l2_dev ;
struct v4l2_ctrl_handler hdl ;
struct video_device * video_dev ;
2020-09-25 21:30:46 +03:00
struct vb2_queue vq ;
2020-09-25 21:30:11 +03:00
struct i2c_adapter i2c_adapter ; /* */
struct i2c_algo_bit_data i2c_algo ; /* */
u32 i2cbr ;
struct v4l2_subdev * decoder ; /* video decoder sub-device */
struct v4l2_subdev * encoder ; /* video encoder sub-device */
struct videocodec * codec ; /* video codec */
struct videocodec * vfe ; /* video front end */
struct mutex lock ; /* file ops serialize lock */
u8 initialized ; /* flag if zoran has been correctly initialized */
struct card_info card ;
2020-09-25 21:30:43 +03:00
const struct tvnorm * timing ;
2020-09-25 21:30:11 +03:00
unsigned short id ; /* number of this device */
media: zoran: increase name size
Fixes this compiler warning:
drivers/media/pci/zoran/zoran_card.c: In function 'zoran_probe':
drivers/media/pci/zoran/zoran_card.c:1316:62: warning: '%u' directive output may be truncated writing between 1 and 5 bytes into a region of size between 0 and 31 [-Wformat-truncation=]
1316 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "%s[%u]",
| ^~
drivers/media/pci/zoran/zoran_card.c:1316:58: note: directive argument in the range [0, 65535]
1316 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "%s[%u]",
| ^~~~~~~~
drivers/media/pci/zoran/zoran_card.c:1316:9: note: 'snprintf' output between 4 and 39 bytes into a destination of size 32
1316 | snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "%s[%u]",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1317 | zr->card.name, zr->id);
| ~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2023-09-23 18:20:54 +03:00
char name [ 40 ] ; /* name of this device */
2020-09-25 21:30:11 +03:00
struct pci_dev * pci_dev ; /* PCI device */
unsigned char revision ; /* revision of zr36057 */
unsigned char __iomem * zr36057_mem ; /* pointer to mapped IO memory */
spinlock_t spinlock ; /* Spinlock */
/* Video for Linux parameters */
int input ; /* card's norm and input */
v4l2_std_id norm ;
/* Current buffer params */
2020-09-25 21:30:26 +03:00
unsigned int buffer_size ;
2020-09-25 21:30:11 +03:00
struct zoran_v4l_settings v4l_settings ; /* structure with a lot of things to play with */
/* 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 */
/* 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 */
unsigned long jpg_que_head ; /* Index where to put next buffer which is queued */
2020-09-25 21:30:15 +03:00
unsigned long jpg_dma_head ; /* Index of next buffer which goes into stat_com */
unsigned long jpg_dma_tail ; /* Index of last buffer in stat_com */
unsigned long jpg_que_tail ; /* Index of last buffer in queue */
unsigned long jpg_seq_num ; /* count of frames since grab/play started */
unsigned long jpg_err_seq ; /* last seq_num before error */
2020-09-25 21:30:11 +03:00
unsigned long jpg_err_shift ;
unsigned long jpg_queued_num ; /* count of frames queued since grab/play started */
2020-09-25 21:30:46 +03:00
unsigned long vbseq ;
2020-09-25 21:30:11 +03:00
/* zr36057's code buffer table */
2022-08-10 14:54:42 +03:00
/* stat_com[i] is indexed by dma_head/tail & BUZ_MASK_STAT_COM */
__le32 * stat_com ;
2020-09-25 21:30:11 +03:00
/* Additional stuff for testing */
2020-09-25 21:30:56 +03:00
unsigned int ghost_int ;
2020-09-25 21:30:11 +03:00
int intr_counter_GIRQ1 ;
int intr_counter_GIRQ0 ;
media: zoran: fix mixed case on vars
Use this small script to replace CamelCase and wrong case
on vars:
<script>
FILES=$(find "$1" -type f|grep -e '.c$' -e '.h$')
CAMEL_VARS=$(cat tags|perl -ne 'print "$1\n" if (m/^(\w*[A-Z]\w*[a-z]\w*)\s/)')
for i in $CAMEL_VARS; do
new=$(perl -e '
my $s = $ARGV[0];
$s =~ s{([^a-zA-Z]?)([A-Z]*)([A-Z])([a-z]?)}{
my $fc = pos($s)==0;
my ($p0,$p1,$p2,$p3) = ($1,lc$2,lc$3,$4);
my $t = $p0 || $fc ? $p0 : '_';
$t .= $p3 ? $p1 ? "${p1}_$p2$p3" : "$p2$p3" : "$p1$p2";
$t;
}ge;
print $s;' "$i")
for j in $FILES; do
sed -E "s,\b$i\b,$new,g" -i $j
done
done
for i in $(git grep "#define zr" drivers/staging/media/zoran/*.[ch]|perl -ne 'print "$1\n" if (m/#define\s+(zr\S+)/)'); do j=$(echo $i|tr [a-z] [A-Z]); sed "s,\b$i\b,$j,g" -i drivers/staging/media/zoran/*.[ch]; done
</script>
This should solve almost all warnings reported by checkpatch.pl
in strict mode.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-10-01 12:15:47 +03:00
int intr_counter_cod_rep_irq ;
int intr_counter_jpeg_rep_irq ;
2020-09-25 21:30:11 +03:00
int field_counter ;
media: zoran: fix mixed case on vars
Use this small script to replace CamelCase and wrong case
on vars:
<script>
FILES=$(find "$1" -type f|grep -e '.c$' -e '.h$')
CAMEL_VARS=$(cat tags|perl -ne 'print "$1\n" if (m/^(\w*[A-Z]\w*[a-z]\w*)\s/)')
for i in $CAMEL_VARS; do
new=$(perl -e '
my $s = $ARGV[0];
$s =~ s{([^a-zA-Z]?)([A-Z]*)([A-Z])([a-z]?)}{
my $fc = pos($s)==0;
my ($p0,$p1,$p2,$p3) = ($1,lc$2,lc$3,$4);
my $t = $p0 || $fc ? $p0 : '_';
$t .= $p3 ? $p1 ? "${p1}_$p2$p3" : "$p2$p3" : "$p1$p2";
$t;
}ge;
print $s;' "$i")
for j in $FILES; do
sed -E "s,\b$i\b,$new,g" -i $j
done
done
for i in $(git grep "#define zr" drivers/staging/media/zoran/*.[ch]|perl -ne 'print "$1\n" if (m/#define\s+(zr\S+)/)'); do j=$(echo $i|tr [a-z] [A-Z]); sed "s,\b$i\b,$j,g" -i drivers/staging/media/zoran/*.[ch]; done
</script>
This should solve almost all warnings reported by checkpatch.pl
in strict mode.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-10-01 12:15:47 +03:00
int irq1_in ;
int irq1_out ;
int jpeg_in ;
int jpeg_out ;
2020-09-25 21:30:11 +03:00
int JPEG_0 ;
int JPEG_1 ;
media: zoran: fix mixed case on vars
Use this small script to replace CamelCase and wrong case
on vars:
<script>
FILES=$(find "$1" -type f|grep -e '.c$' -e '.h$')
CAMEL_VARS=$(cat tags|perl -ne 'print "$1\n" if (m/^(\w*[A-Z]\w*[a-z]\w*)\s/)')
for i in $CAMEL_VARS; do
new=$(perl -e '
my $s = $ARGV[0];
$s =~ s{([^a-zA-Z]?)([A-Z]*)([A-Z])([a-z]?)}{
my $fc = pos($s)==0;
my ($p0,$p1,$p2,$p3) = ($1,lc$2,lc$3,$4);
my $t = $p0 || $fc ? $p0 : '_';
$t .= $p3 ? $p1 ? "${p1}_$p2$p3" : "$p2$p3" : "$p1$p2";
$t;
}ge;
print $s;' "$i")
for j in $FILES; do
sed -E "s,\b$i\b,$new,g" -i $j
done
done
for i in $(git grep "#define zr" drivers/staging/media/zoran/*.[ch]|perl -ne 'print "$1\n" if (m/#define\s+(zr\S+)/)'); do j=$(echo $i|tr [a-z] [A-Z]); sed "s,\b$i\b,$j,g" -i drivers/staging/media/zoran/*.[ch]; done
</script>
This should solve almost all warnings reported by checkpatch.pl
in strict mode.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-10-01 12:15:47 +03:00
int end_event_missed ;
int jpeg_missed ;
int jpeg_error ;
2020-09-25 21:30:11 +03:00
int num_errors ;
media: zoran: fix mixed case on vars
Use this small script to replace CamelCase and wrong case
on vars:
<script>
FILES=$(find "$1" -type f|grep -e '.c$' -e '.h$')
CAMEL_VARS=$(cat tags|perl -ne 'print "$1\n" if (m/^(\w*[A-Z]\w*[a-z]\w*)\s/)')
for i in $CAMEL_VARS; do
new=$(perl -e '
my $s = $ARGV[0];
$s =~ s{([^a-zA-Z]?)([A-Z]*)([A-Z])([a-z]?)}{
my $fc = pos($s)==0;
my ($p0,$p1,$p2,$p3) = ($1,lc$2,lc$3,$4);
my $t = $p0 || $fc ? $p0 : '_';
$t .= $p3 ? $p1 ? "${p1}_$p2$p3" : "$p2$p3" : "$p1$p2";
$t;
}ge;
print $s;' "$i")
for j in $FILES; do
sed -E "s,\b$i\b,$new,g" -i $j
done
done
for i in $(git grep "#define zr" drivers/staging/media/zoran/*.[ch]|perl -ne 'print "$1\n" if (m/#define\s+(zr\S+)/)'); do j=$(echo $i|tr [a-z] [A-Z]); sed "s,\b$i\b,$j,g" -i drivers/staging/media/zoran/*.[ch]; done
</script>
This should solve almost all warnings reported by checkpatch.pl
in strict mode.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-10-01 12:15:47 +03:00
int jpeg_max_missed ;
int jpeg_min_missed ;
2020-09-25 21:30:46 +03:00
unsigned int prepared ;
unsigned int queued ;
2020-09-25 21:30:11 +03:00
u32 last_isr ;
unsigned long frame_num ;
2020-09-25 21:30:46 +03:00
int running ;
int buf_in_reserve ;
2020-09-25 21:30:11 +03:00
2020-09-25 21:30:33 +03:00
dma_addr_t p_sc ;
2020-09-25 21:30:42 +03:00
__le32 * stat_comb ;
dma_addr_t p_scb ;
2020-09-25 21:30:46 +03:00
enum zoran_map_mode map_mode ;
struct list_head queued_bufs ;
spinlock_t queued_bufs_lock ; /* Protects queued_bufs */
struct zr_buffer * inuse [ BUZ_NUM_STAT_COM * 2 ] ;
2021-12-14 19:16:22 +03:00
struct dentry * dbgfs_dir ;
2020-09-25 21:30:11 +03:00
} ;
static inline struct zoran * to_zoran ( struct v4l2_device * v4l2_dev )
{
return container_of ( v4l2_dev , struct zoran , v4l2_dev ) ;
}
2022-08-10 14:54:42 +03:00
/*
* There was something called _ALPHA_BUZ that used the PCI address instead of
* the kernel iomapped address for btread / btwrite .
*/
2020-09-25 21:30:15 +03:00
# define btwrite(dat, adr) writel((dat), zr->zr36057_mem + (adr))
# define btread(adr) readl(zr->zr36057_mem + (adr))
2020-09-25 21:30:11 +03:00
2022-08-10 14:54:42 +03:00
# 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))
2020-09-25 21:30:11 +03:00
# endif
2020-09-25 21:30:46 +03:00
2022-05-06 08:28:00 +03:00
/*
* Debugging macros
*/
# define zrdev_dbg(zr, format, args...) \
pci_dbg ( ( zr ) - > pci_dev , format , # # args ) \
# define zrdev_err(zr, format, args...) \
pci_err ( ( zr ) - > pci_dev , format , # # args ) \
# define zrdev_info(zr, format, args...) \
pci_info ( ( zr ) - > pci_dev , format , # # args ) \
2021-12-14 19:16:26 +03:00
int zoran_queue_init ( struct zoran * zr , struct vb2_queue * vq , int dir ) ;
2020-09-25 21:30:46 +03:00
void zoran_queue_exit ( struct zoran * zr ) ;
int zr_set_buf ( struct zoran * zr ) ;