diff options
Diffstat (limited to 'drivers/media/pci/cx88/cx88-blackbird.c')
-rw-r--r-- | drivers/media/pci/cx88/cx88-blackbird.c | 292 |
1 files changed, 160 insertions, 132 deletions
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c index b532e49e8f33..aa49c9597d9c 100644 --- a/drivers/media/pci/cx88/cx88-blackbird.c +++ b/drivers/media/pci/cx88/cx88-blackbird.c @@ -1,5 +1,4 @@ /* - * * Support for a cx23416 mpeg encoder via cx2388x host port. * "blackbird" reference design. * @@ -20,12 +19,10 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "cx88.h" + #include <linux/module.h> #include <linux/init.h> #include <linux/slab.h> @@ -38,21 +35,20 @@ #include <media/v4l2-event.h> #include <media/drv-intf/cx2341x.h> -#include "cx88.h" - MODULE_DESCRIPTION("driver for cx2388x/cx23416 based mpeg encoder cards"); MODULE_AUTHOR("Jelle Foks <jelle@foks.us>, Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); MODULE_LICENSE("GPL"); MODULE_VERSION(CX88_VERSION); static unsigned int debug; -module_param(debug,int,0644); -MODULE_PARM_DESC(debug,"enable debug messages [blackbird]"); +module_param(debug, int, 0644); +MODULE_PARM_DESC(debug, "enable debug messages [blackbird]"); -#define dprintk(level, fmt, arg...) do { \ - if (debug + 1 > level) \ - printk(KERN_DEBUG "%s/2-bb: " fmt, dev->core->name , ## arg); \ -} while(0) +#define dprintk(level, fmt, arg...) do { \ + if (debug + 1 > level) \ + printk(KERN_DEBUG pr_fmt("%s: blackbird:" fmt), \ + __func__, ##arg); \ +} while (0) /* ------------------------------------------------------------------ */ @@ -70,6 +66,7 @@ enum blackbird_capture_type { BLACKBIRD_RAW_CAPTURE, BLACKBIRD_RAW_PASSTHRU_CAPTURE }; + enum blackbird_capture_bits { BLACKBIRD_RAW_BITS_NONE = 0x00, BLACKBIRD_RAW_BITS_YUV_CAPTURE = 0x01, @@ -78,33 +75,40 @@ enum blackbird_capture_bits { BLACKBIRD_RAW_BITS_PASSTHRU_CAPTURE = 0x08, BLACKBIRD_RAW_BITS_TO_HOST_CAPTURE = 0x10 }; + enum blackbird_capture_end { BLACKBIRD_END_AT_GOP, /* stop at the end of gop, generate irq */ BLACKBIRD_END_NOW, /* stop immediately, no irq */ }; + enum blackbird_framerate { BLACKBIRD_FRAMERATE_NTSC_30, /* NTSC: 30fps */ BLACKBIRD_FRAMERATE_PAL_25 /* PAL: 25fps */ }; + enum blackbird_stream_port { BLACKBIRD_OUTPUT_PORT_MEMORY, BLACKBIRD_OUTPUT_PORT_STREAMING, BLACKBIRD_OUTPUT_PORT_SERIAL }; + enum blackbird_data_xfer_status { BLACKBIRD_MORE_BUFFERS_FOLLOW, BLACKBIRD_LAST_BUFFER, }; + enum blackbird_picture_mask { BLACKBIRD_PICTURE_MASK_NONE, BLACKBIRD_PICTURE_MASK_I_FRAMES, BLACKBIRD_PICTURE_MASK_I_P_FRAMES = 0x3, BLACKBIRD_PICTURE_MASK_ALL_FRAMES = 0x7, }; + enum blackbird_vbi_mode_bits { BLACKBIRD_VBI_BITS_SLICED, BLACKBIRD_VBI_BITS_RAW, }; + enum blackbird_vbi_insertion_bits { BLACKBIRD_VBI_BITS_INSERT_IN_XTENSION_USR_DATA, BLACKBIRD_VBI_BITS_INSERT_IN_PRIVATE_PACKETS = 0x1 << 1, @@ -112,56 +116,69 @@ enum blackbird_vbi_insertion_bits { BLACKBIRD_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1, BLACKBIRD_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1, }; + enum blackbird_dma_unit { BLACKBIRD_DMA_BYTES, BLACKBIRD_DMA_FRAMES, }; + enum blackbird_dma_transfer_status_bits { BLACKBIRD_DMA_TRANSFER_BITS_DONE = 0x01, BLACKBIRD_DMA_TRANSFER_BITS_ERROR = 0x04, BLACKBIRD_DMA_TRANSFER_BITS_LL_ERROR = 0x10, }; + enum blackbird_pause { BLACKBIRD_PAUSE_ENCODING, BLACKBIRD_RESUME_ENCODING, }; + enum blackbird_copyright { BLACKBIRD_COPYRIGHT_OFF, BLACKBIRD_COPYRIGHT_ON, }; + enum blackbird_notification_type { BLACKBIRD_NOTIFICATION_REFRESH, }; + enum blackbird_notification_status { BLACKBIRD_NOTIFICATION_OFF, BLACKBIRD_NOTIFICATION_ON, }; + enum blackbird_notification_mailbox { BLACKBIRD_NOTIFICATION_NO_MAILBOX = -1, }; + enum blackbird_field1_lines { BLACKBIRD_FIELD1_SAA7114 = 0x00EF, /* 239 */ BLACKBIRD_FIELD1_SAA7115 = 0x00F0, /* 240 */ BLACKBIRD_FIELD1_MICRONAS = 0x0105, /* 261 */ }; + enum blackbird_field2_lines { BLACKBIRD_FIELD2_SAA7114 = 0x00EF, /* 239 */ BLACKBIRD_FIELD2_SAA7115 = 0x00F0, /* 240 */ BLACKBIRD_FIELD2_MICRONAS = 0x0106, /* 262 */ }; + enum blackbird_custom_data_type { BLACKBIRD_CUSTOM_EXTENSION_USR_DATA, BLACKBIRD_CUSTOM_PRIVATE_PACKET, }; + enum blackbird_mute { BLACKBIRD_UNMUTE, BLACKBIRD_MUTE, }; + enum blackbird_mute_video_mask { BLACKBIRD_MUTE_VIDEO_V_MASK = 0x0000FF00, BLACKBIRD_MUTE_VIDEO_U_MASK = 0x00FF0000, BLACKBIRD_MUTE_VIDEO_Y_MASK = 0xFF000000, }; + enum blackbird_mute_video_shift { BLACKBIRD_MUTE_VIDEO_V_SHIFT = 8, BLACKBIRD_MUTE_VIDEO_U_SHIFT = 16, @@ -215,14 +232,14 @@ static void host_setup(struct cx88_core *core) static int wait_ready_gpio0_bit1(struct cx88_core *core, u32 state) { unsigned long timeout = jiffies + msecs_to_jiffies(1); - u32 gpio0,need; + u32 gpio0, need; need = state ? 2 : 0; for (;;) { gpio0 = cx_read(MO_GP0_IO) & 2; if (need == gpio0) return 0; - if (time_after(jiffies,timeout)) + if (time_after(jiffies, timeout)) return -1; udelay(1); } @@ -241,7 +258,7 @@ static int memory_write(struct cx88_core *core, u32 address, u32 value) cx_read(P1_MDATA0); cx_read(P1_MADDR0); - return wait_ready_gpio0_bit1(core,1); + return wait_ready_gpio0_bit1(core, 1); } static int memory_read(struct cx88_core *core, u32 address, u32 *value) @@ -255,7 +272,7 @@ static int memory_read(struct cx88_core *core, u32 address, u32 *value) cx_writeb(P1_MADDR0, (unsigned int)address); cx_read(P1_MADDR0); - retval = wait_ready_gpio0_bit1(core,1); + retval = wait_ready_gpio0_bit1(core, 1); cx_writeb(P1_MDATA3, 0); val = (unsigned char)cx_read(P1_MDATA3) << 24; @@ -282,10 +299,9 @@ static int register_write(struct cx88_core *core, u32 address, u32 value) cx_read(P1_RDATA0); cx_read(P1_RADDR0); - return wait_ready_gpio0_bit1(core,1); + return wait_ready_gpio0_bit1(core, 1); } - static int register_read(struct cx88_core *core, u32 address, u32 *value) { int retval; @@ -296,7 +312,7 @@ static int register_read(struct cx88_core *core, u32 address, u32 *value) cx_writeb(P1_RRDWR, 0); cx_read(P1_RADDR0); - retval = wait_ready_gpio0_bit1(core,1); + retval = wait_ready_gpio0_bit1(core, 1); val = (unsigned char)cx_read(P1_RDATA0); val |= (unsigned char)cx_read(P1_RDATA1) << 8; val |= (unsigned char)cx_read(P1_RDATA2) << 16; @@ -308,20 +324,24 @@ static int register_read(struct cx88_core *core, u32 address, u32 *value) /* ------------------------------------------------------------------ */ -static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 data[CX2341X_MBOX_MAX_DATA]) +static int blackbird_mbox_func(void *priv, u32 command, int in, + int out, u32 data[CX2341X_MBOX_MAX_DATA]) { struct cx8802_dev *dev = priv; unsigned long timeout; u32 value, flag, retval; int i; - dprintk(1,"%s: 0x%X\n", __func__, command); + dprintk(1, "%s: 0x%X\n", __func__, command); - /* this may not be 100% safe if we can't read any memory location - without side effects */ + /* + * this may not be 100% safe if we can't read any memory location + * without side effects + */ memory_read(dev->core, dev->mailbox - 4, &value); if (value != 0x12345678) { - dprintk(0, "Firmware and/or mailbox pointer not initialized or corrupted\n"); + dprintk(0, + "Firmware and/or mailbox pointer not initialized or corrupted\n"); return -EIO; } @@ -336,7 +356,8 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat /* write command + args + fill remaining with zeros */ memory_write(dev->core, dev->mailbox + 1, command); /* command code */ - memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT); /* timeout */ + /* timeout */ + memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT); for (i = 0; i < in; i++) { memory_write(dev->core, dev->mailbox + 4 + i, data[i]); dprintk(1, "API Input %d = %d\n", i, data[i]); @@ -353,7 +374,7 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat memory_read(dev->core, dev->mailbox, &flag); if (0 != (flag & 4)) break; - if (time_after(jiffies,timeout)) { + if (time_after(jiffies, timeout)) { dprintk(0, "ERROR: API Mailbox timeout %x\n", command); return -EIO; } @@ -367,15 +388,19 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat } memory_read(dev->core, dev->mailbox + 2, &retval); - dprintk(1, "API result = %d\n",retval); + dprintk(1, "API result = %d\n", retval); flag = 0; memory_write(dev->core, dev->mailbox, flag); return retval; } + /* ------------------------------------------------------------------ */ -/* We don't need to call the API often, so using just one mailbox will probably suffice */ +/* + * We don't need to call the API often, so using just one mailbox + * will probably suffice + */ static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command, u32 inputcnt, u32 outputcnt, ...) { @@ -385,9 +410,9 @@ static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command, va_start(vargs, outputcnt); - for (i = 0; i < inputcnt; i++) { + for (i = 0; i < inputcnt; i++) data[i] = va_arg(vargs, int); - } + err = blackbird_mbox_func(dev, command, inputcnt, outputcnt, data); for (i = 0; i < outputcnt; i++) { int *vptr = va_arg(vargs, int *); @@ -399,8 +424,8 @@ static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command, static int blackbird_find_mailbox(struct cx8802_dev *dev) { - u32 signature[4]={0x12345678, 0x34567812, 0x56781234, 0x78123456}; - int signaturecnt=0; + u32 signature[4] = {0x12345678, 0x34567812, 0x56781234, 0x78123456}; + int signaturecnt = 0; u32 value; int i; @@ -410,9 +435,9 @@ static int blackbird_find_mailbox(struct cx8802_dev *dev) signaturecnt++; else signaturecnt = 0; - if (4 == signaturecnt) { + if (signaturecnt == 4) { dprintk(1, "Mailbox signature found\n"); - return i+1; + return i + 1; } } dprintk(0, "Mailbox signature values not found!\n"); @@ -431,10 +456,13 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) __le32 *dataptr; retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED); - retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); - retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH, 0x80000640); - retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE, 0x1A); - msleep(1); + retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, + IVTV_CMD_HW_BLOCKS_RST); + retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH, + 0x80000640); + retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE, + 0x1A); + usleep_range(10000, 20000); retval |= register_write(dev->core, IVTV_REG_APU, 0); if (retval < 0) @@ -443,29 +471,28 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) retval = request_firmware(&firmware, CX2341X_FIRM_ENC_FILENAME, &dev->pci->dev); - if (retval != 0) { pr_err("Hotplug firmware request failed (%s).\n", - CX2341X_FIRM_ENC_FILENAME); + CX2341X_FIRM_ENC_FILENAME); pr_err("Please fix your hotplug setup, the board will not work without firmware loaded!\n"); return -EIO; } if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) { pr_err("Firmware size mismatch (have %zd, expected %d)\n", - firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE); + firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE); release_firmware(firmware); return -EINVAL; } - if (0 != memcmp(firmware->data, magic, 8)) { + if (memcmp(firmware->data, magic, 8) != 0) { pr_err("Firmware magic mismatch, wrong file?\n"); release_firmware(firmware); return -EINVAL; } /* transfer to the chip */ - dprintk(1,"Loading firmware ...\n"); + dprintk(1, "Loading firmware ...\n"); dataptr = (__le32 *)firmware->data; for (i = 0; i < (firmware->size >> 2); i++) { value = le32_to_cpu(*dataptr); @@ -486,10 +513,11 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) } dprintk(0, "Firmware upload successful.\n"); - retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); + retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, + IVTV_CMD_HW_BLOCKS_RST); retval |= register_read(dev->core, IVTV_REG_SPU, &value); retval |= register_write(dev->core, IVTV_REG_SPU, value & 0xFFFFFFFE); - msleep(1); + usleep_range(10000, 20000); retval |= register_read(dev->core, IVTV_REG_VPU, &value); retval |= register_write(dev->core, IVTV_REG_VPU, value & 0xFFFFFFE8); @@ -499,19 +527,19 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) return 0; } -/** - Settings used by the windows tv app for PVR2000: -================================================================================================================= -Profile | Codec | Resolution | CBR/VBR | Video Qlty | V. Bitrate | Frmrate | Audio Codec | A. Bitrate | A. Mode ------------------------------------------------------------------------------------------------------------------ -MPEG-1 | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 2000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo -MPEG-2 | MPEG2 | 720x576PAL | VBR | 600 :Good | 4000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo -VCD | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 1150 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo -DVD | MPEG2 | 720x576PAL | VBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo -DB* DVD | MPEG2 | 720x576PAL | CBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo -================================================================================================================= -*DB: "DirectBurn" -*/ +/* + * Settings used by the windows tv app for PVR2000: + * ================================================================================================================= + * Profile | Codec | Resolution | CBR/VBR | Video Qlty | V. Bitrate | Frmrate | Audio Codec | A. Bitrate | A. Mode + * ----------------------------------------------------------------------------------------------------------------- + * MPEG-1 | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 2000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo + * MPEG-2 | MPEG2 | 720x576PAL | VBR | 600 :Good | 4000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo + * VCD | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 1150 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo + * DVD | MPEG2 | 720x576PAL | VBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo + * DB* DVD | MPEG2 | 720x576PAL | CBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo + * ================================================================================================================= + * [*] DB: "DirectBurn" + */ static void blackbird_codec_settings(struct cx8802_dev *dev) { @@ -519,11 +547,12 @@ static void blackbird_codec_settings(struct cx8802_dev *dev) /* assign frame size */ blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, - core->height, core->width); + core->height, core->width); dev->cxhdl.width = core->width; dev->cxhdl.height = core->height; - cx2341x_handler_set_50hz(&dev->cxhdl, dev->core->tvnorm & V4L2_STD_625_50); + cx2341x_handler_set_50hz(&dev->cxhdl, + dev->core->tvnorm & V4L2_STD_625_50); cx2341x_handler_setup(&dev->cxhdl); } @@ -533,7 +562,7 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) int version; int retval; - dprintk(1,"Initialize codec\n"); + dprintk(1, "Initialize codec\n"); retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ if (retval < 0) { /* ping was not successful, reset and upload firmware */ @@ -549,15 +578,18 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) dev->mailbox = retval; - retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ + /* ping */ + retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); if (retval < 0) { dprintk(0, "ERROR: Firmware ping failed!\n"); return -1; } - retval = blackbird_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, &version); + retval = blackbird_api_cmd(dev, CX2341X_ENC_GET_VERSION, + 0, 1, &version); if (retval < 0) { - dprintk(0, "ERROR: Firmware get encoder version failed!\n"); + dprintk(0, + "ERROR: Firmware get encoder version failed!\n"); return -1; } dprintk(0, "Firmware version is 0x%08x\n", version); @@ -571,13 +603,11 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev) blackbird_codec_settings(dev); blackbird_api_cmd(dev, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 0, - BLACKBIRD_FIELD1_SAA7115, - BLACKBIRD_FIELD2_SAA7115 - ); + BLACKBIRD_FIELD1_SAA7115, BLACKBIRD_FIELD2_SAA7115); blackbird_api_cmd(dev, CX2341X_ENC_SET_PLACEHOLDER, 12, 0, - BLACKBIRD_CUSTOM_EXTENSION_USR_DATA, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + BLACKBIRD_CUSTOM_EXTENSION_USR_DATA, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); return 0; } @@ -615,9 +645,7 @@ static int blackbird_start_codec(struct cx8802_dev *dev) /* start capturing to the host interface */ blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0, - BLACKBIRD_MPEG_CAPTURE, - BLACKBIRD_RAW_BITS_NONE - ); + BLACKBIRD_MPEG_CAPTURE, BLACKBIRD_RAW_BITS_NONE); return 0; } @@ -625,10 +653,9 @@ static int blackbird_start_codec(struct cx8802_dev *dev) static int blackbird_stop_codec(struct cx8802_dev *dev) { blackbird_api_cmd(dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, - BLACKBIRD_END_NOW, - BLACKBIRD_MPEG_CAPTURE, - BLACKBIRD_RAW_BITS_NONE - ); + BLACKBIRD_END_NOW, + BLACKBIRD_MPEG_CAPTURE, + BLACKBIRD_RAW_BITS_NONE); cx2341x_handler_set_busy(&dev->cxhdl, 0); @@ -638,8 +665,8 @@ static int blackbird_stop_codec(struct cx8802_dev *dev) /* ------------------------------------------------------------------ */ static int queue_setup(struct vb2_queue *q, - unsigned int *num_buffers, unsigned int *num_planes, - unsigned int sizes[], struct device *alloc_devs[]) + unsigned int *num_buffers, unsigned int *num_planes, + unsigned int sizes[], struct device *alloc_devs[]) { struct cx8802_dev *dev = q->drv_priv; @@ -699,7 +726,8 @@ static int start_streaming(struct vb2_queue *q, unsigned int count) err = drv->request_acquire(drv); if (err != 0) { - dprintk(1, "%s: Unable to acquire hardware, %d\n", __func__, err); + dprintk(1, "%s: Unable to acquire hardware, %d\n", __func__, + err); goto fail; } @@ -770,7 +798,7 @@ static const struct vb2_ops blackbird_qops = { /* ------------------------------------------------------------------ */ static int vidioc_querycap(struct file *file, void *priv, - struct v4l2_capability *cap) + struct v4l2_capability *cap) { struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; @@ -781,8 +809,8 @@ static int vidioc_querycap(struct file *file, void *priv, return 0; } -static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, - struct v4l2_fmtdesc *f) +static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, + struct v4l2_fmtdesc *f) { if (f->index != 0) return -EINVAL; @@ -794,7 +822,7 @@ static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, } static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f) + struct v4l2_format *f) { struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; @@ -810,11 +838,11 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, } static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f) + struct v4l2_format *f) { struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; - unsigned maxw, maxh; + unsigned int maxw, maxh; enum v4l2_field field; f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; @@ -850,7 +878,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, } static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, - struct v4l2_format *f) + struct v4l2_format *f) { struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; @@ -864,20 +892,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, core->width = f->fmt.pix.width; core->height = f->fmt.pix.height; core->field = f->fmt.pix.field; - cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); + cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height, + f->fmt.pix.field); blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, - f->fmt.pix.height, f->fmt.pix.width); + f->fmt.pix.height, f->fmt.pix.width); return 0; } -static int vidioc_s_frequency (struct file *file, void *priv, - const struct v4l2_frequency *f) +static int vidioc_s_frequency(struct file *file, void *priv, + const struct v4l2_frequency *f) { struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; bool streaming; - if (unlikely(UNSET == core->board.tuner_type)) + if (unlikely(core->board.tuner_type == UNSET)) return -EINVAL; if (unlikely(f->tuner != 0)) return -EINVAL; @@ -885,16 +914,15 @@ static int vidioc_s_frequency (struct file *file, void *priv, if (streaming) blackbird_stop_codec(dev); - cx88_set_freq (core,f); + cx88_set_freq(core, f); blackbird_initialize_codec(dev); - cx88_set_scale(core, core->width, core->height, - core->field); + cx88_set_scale(core, core->width, core->height, core->field); if (streaming) blackbird_start_codec(dev); return 0; } -static int vidioc_log_status (struct file *file, void *priv) +static int vidioc_log_status(struct file *file, void *priv) { struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; @@ -906,21 +934,22 @@ static int vidioc_log_status (struct file *file, void *priv) return 0; } -static int vidioc_enum_input (struct file *file, void *priv, - struct v4l2_input *i) +static int vidioc_enum_input(struct file *file, void *priv, + struct v4l2_input *i) { struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; - return cx88_enum_input (core,i); + + return cx88_enum_input(core, i); } -static int vidioc_g_frequency (struct file *file, void *priv, - struct v4l2_frequency *f) +static int vidioc_g_frequency(struct file *file, void *priv, + struct v4l2_frequency *f) { struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; - if (unlikely(UNSET == core->board.tuner_type)) + if (unlikely(core->board.tuner_type == UNSET)) return -EINVAL; if (unlikely(f->tuner != 0)) return -EINVAL; @@ -931,7 +960,7 @@ static int vidioc_g_frequency (struct file *file, void *priv, return 0; } -static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) +static int vidioc_g_input(struct file *file, void *priv, unsigned int *i) { struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; @@ -940,31 +969,31 @@ static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) return 0; } -static int vidioc_s_input (struct file *file, void *priv, unsigned int i) +static int vidioc_s_input(struct file *file, void *priv, unsigned int i) { struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; if (i >= 4) return -EINVAL; - if (0 == INPUT(i).type) + if (!INPUT(i).type) return -EINVAL; cx88_newstation(core); - cx88_video_mux(core,i); + cx88_video_mux(core, i); return 0; } -static int vidioc_g_tuner (struct file *file, void *priv, - struct v4l2_tuner *t) +static int vidioc_g_tuner(struct file *file, void *priv, + struct v4l2_tuner *t) { struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; u32 reg; - if (unlikely(UNSET == core->board.tuner_type)) + if (unlikely(core->board.tuner_type == UNSET)) return -EINVAL; - if (0 != t->index) + if (t->index != 0) return -EINVAL; strcpy(t->name, "Television"); @@ -972,21 +1001,21 @@ static int vidioc_g_tuner (struct file *file, void *priv, t->rangehigh = 0xffffffffUL; call_all(core, tuner, g_tuner, t); - cx88_get_stereo(core ,t); + cx88_get_stereo(core, t); reg = cx_read(MO_DEVICE_STATUS); - t->signal = (reg & (1<<5)) ? 0xffff : 0x0000; + t->signal = (reg & (1 << 5)) ? 0xffff : 0x0000; return 0; } -static int vidioc_s_tuner (struct file *file, void *priv, - const struct v4l2_tuner *t) +static int vidioc_s_tuner(struct file *file, void *priv, + const struct v4l2_tuner *t) { struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; - if (UNSET == core->board.tuner_type) + if (core->board.tuner_type == UNSET) return -EINVAL; - if (0 != t->index) + if (t->index != 0) return -EINVAL; cx88_set_stereo(core, t->audmode, 1); @@ -1010,8 +1039,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) return cx88_set_tvnorm(core, id); } -static const struct v4l2_file_operations mpeg_fops = -{ +static const struct v4l2_file_operations mpeg_fops = { .owner = THIS_MODULE, .open = v4l2_fh_open, .release = vb2_fop_release, @@ -1050,7 +1078,7 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { static struct video_device cx8802_mpeg_template = { .name = "cx8802", .fops = &mpeg_fops, - .ioctl_ops = &mpeg_ioctl_ops, + .ioctl_ops = &mpeg_ioctl_ops, .tvnorms = CX88_NORMS, }; @@ -1064,7 +1092,9 @@ static int cx8802_blackbird_advise_acquire(struct cx8802_driver *drv) switch (core->boardnr) { case CX88_BOARD_HAUPPAUGE_HVR1300: - /* By default, core setup will leave the cx22702 out of reset, on the bus. + /* + * By default, core setup will leave the cx22702 out of reset, + * on the bus. * We left the hardware on power up with the cx22702 active. * We're being given access to re-arrange the GPIOs. * Take the bus off the cx22702 and put the cx23416 on it. @@ -1118,12 +1148,11 @@ static int blackbird_register_video(struct cx8802_dev *dev) dev->mpeg_dev.queue = &dev->vb2_mpegq; err = video_register_device(&dev->mpeg_dev, VFL_TYPE_GRABBER, -1); if (err < 0) { - printk(KERN_INFO "%s/2: can't register mpeg device\n", - dev->core->name); + pr_info("can't register mpeg device\n"); return err; } - printk(KERN_INFO "%s/2: registered device %s [mpeg]\n", - dev->core->name, video_device_node_name(&dev->mpeg_dev)); + pr_info("registered device %s [mpeg]\n", + video_device_node_name(&dev->mpeg_dev)); return 0; } @@ -1136,8 +1165,8 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) struct vb2_queue *q; int err; - dprintk( 1, "%s\n", __func__); - dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", + dprintk(1, "%s\n", __func__); + dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", core->boardnr, core->name, core->pci_bus, @@ -1158,16 +1187,15 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) v4l2_ctrl_add_handler(&dev->cxhdl.hdl, &core->video_hdl, NULL); /* blackbird stuff */ - printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n", - core->name); + pr_info("cx23416 based mpeg encoder (blackbird reference design)\n"); host_setup(dev->core); blackbird_initialize_codec(dev); /* initial device configuration: needed ? */ // init_controls(core); - cx88_set_tvnorm(core,core->tvnorm); - cx88_video_mux(core,0); + cx88_set_tvnorm(core, core->tvnorm); + cx88_video_mux(core, 0); cx2341x_handler_set_50hz(&dev->cxhdl, core->height == 576); cx2341x_handler_setup(&dev->cxhdl); @@ -1219,8 +1247,8 @@ static struct cx8802_driver cx8802_blackbird_driver = { static int __init blackbird_init(void) { - printk(KERN_INFO "cx2388x blackbird driver version %s loaded\n", - CX88_VERSION); + pr_info("cx2388x blackbird driver version %s loaded\n", + CX88_VERSION); return cx8802_register_driver(&cx8802_blackbird_driver); } |