Path: blob/master/drivers/media/video/cx88/cx88-blackbird.c
17751 views
/*1*2* Support for a cx23416 mpeg encoder via cx2388x host port.3* "blackbird" reference design.4*5* (c) 2004 Jelle Foks <[email protected]>6* (c) 2004 Gerd Knorr <[email protected]>7*8* (c) 2005-2006 Mauro Carvalho Chehab <[email protected]>9* - video_ioctl2 conversion10*11* Includes parts from the ivtv driver <http://sourceforge.net/projects/ivtv/>12*13* This program is free software; you can redistribute it and/or modify14* it under the terms of the GNU General Public License as published by15* the Free Software Foundation; either version 2 of the License, or16* (at your option) any later version.17*18* This program is distributed in the hope that it will be useful,19* but WITHOUT ANY WARRANTY; without even the implied warranty of20* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the21* GNU General Public License for more details.22*23* You should have received a copy of the GNU General Public License24* along with this program; if not, write to the Free Software25* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.26*/2728#include <linux/module.h>29#include <linux/init.h>30#include <linux/slab.h>31#include <linux/fs.h>32#include <linux/delay.h>33#include <linux/device.h>34#include <linux/firmware.h>35#include <media/v4l2-common.h>36#include <media/v4l2-ioctl.h>37#include <media/cx2341x.h>3839#include "cx88.h"4041MODULE_DESCRIPTION("driver for cx2388x/cx23416 based mpeg encoder cards");42MODULE_AUTHOR("Jelle Foks <[email protected]>, Gerd Knorr <[email protected]> [SuSE Labs]");43MODULE_LICENSE("GPL");4445static unsigned int mpegbufs = 32;46module_param(mpegbufs,int,0644);47MODULE_PARM_DESC(mpegbufs,"number of mpeg buffers, range 2-32");4849static unsigned int debug;50module_param(debug,int,0644);51MODULE_PARM_DESC(debug,"enable debug messages [blackbird]");5253#define dprintk(level,fmt, arg...) if (debug >= level) \54printk(KERN_DEBUG "%s/2-bb: " fmt, dev->core->name , ## arg)555657/* ------------------------------------------------------------------ */5859#define BLACKBIRD_FIRM_IMAGE_SIZE 3768366061/* defines below are from ivtv-driver.h */6263#define IVTV_CMD_HW_BLOCKS_RST 0xFFFFFFFF6465/* Firmware API commands */66#define IVTV_API_STD_TIMEOUT 5006768enum blackbird_capture_type {69BLACKBIRD_MPEG_CAPTURE,70BLACKBIRD_RAW_CAPTURE,71BLACKBIRD_RAW_PASSTHRU_CAPTURE72};73enum blackbird_capture_bits {74BLACKBIRD_RAW_BITS_NONE = 0x00,75BLACKBIRD_RAW_BITS_YUV_CAPTURE = 0x01,76BLACKBIRD_RAW_BITS_PCM_CAPTURE = 0x02,77BLACKBIRD_RAW_BITS_VBI_CAPTURE = 0x04,78BLACKBIRD_RAW_BITS_PASSTHRU_CAPTURE = 0x08,79BLACKBIRD_RAW_BITS_TO_HOST_CAPTURE = 0x1080};81enum blackbird_capture_end {82BLACKBIRD_END_AT_GOP, /* stop at the end of gop, generate irq */83BLACKBIRD_END_NOW, /* stop immediately, no irq */84};85enum blackbird_framerate {86BLACKBIRD_FRAMERATE_NTSC_30, /* NTSC: 30fps */87BLACKBIRD_FRAMERATE_PAL_25 /* PAL: 25fps */88};89enum blackbird_stream_port {90BLACKBIRD_OUTPUT_PORT_MEMORY,91BLACKBIRD_OUTPUT_PORT_STREAMING,92BLACKBIRD_OUTPUT_PORT_SERIAL93};94enum blackbird_data_xfer_status {95BLACKBIRD_MORE_BUFFERS_FOLLOW,96BLACKBIRD_LAST_BUFFER,97};98enum blackbird_picture_mask {99BLACKBIRD_PICTURE_MASK_NONE,100BLACKBIRD_PICTURE_MASK_I_FRAMES,101BLACKBIRD_PICTURE_MASK_I_P_FRAMES = 0x3,102BLACKBIRD_PICTURE_MASK_ALL_FRAMES = 0x7,103};104enum blackbird_vbi_mode_bits {105BLACKBIRD_VBI_BITS_SLICED,106BLACKBIRD_VBI_BITS_RAW,107};108enum blackbird_vbi_insertion_bits {109BLACKBIRD_VBI_BITS_INSERT_IN_XTENSION_USR_DATA,110BLACKBIRD_VBI_BITS_INSERT_IN_PRIVATE_PACKETS = 0x1 << 1,111BLACKBIRD_VBI_BITS_SEPARATE_STREAM = 0x2 << 1,112BLACKBIRD_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1,113BLACKBIRD_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1,114};115enum blackbird_dma_unit {116BLACKBIRD_DMA_BYTES,117BLACKBIRD_DMA_FRAMES,118};119enum blackbird_dma_transfer_status_bits {120BLACKBIRD_DMA_TRANSFER_BITS_DONE = 0x01,121BLACKBIRD_DMA_TRANSFER_BITS_ERROR = 0x04,122BLACKBIRD_DMA_TRANSFER_BITS_LL_ERROR = 0x10,123};124enum blackbird_pause {125BLACKBIRD_PAUSE_ENCODING,126BLACKBIRD_RESUME_ENCODING,127};128enum blackbird_copyright {129BLACKBIRD_COPYRIGHT_OFF,130BLACKBIRD_COPYRIGHT_ON,131};132enum blackbird_notification_type {133BLACKBIRD_NOTIFICATION_REFRESH,134};135enum blackbird_notification_status {136BLACKBIRD_NOTIFICATION_OFF,137BLACKBIRD_NOTIFICATION_ON,138};139enum blackbird_notification_mailbox {140BLACKBIRD_NOTIFICATION_NO_MAILBOX = -1,141};142enum blackbird_field1_lines {143BLACKBIRD_FIELD1_SAA7114 = 0x00EF, /* 239 */144BLACKBIRD_FIELD1_SAA7115 = 0x00F0, /* 240 */145BLACKBIRD_FIELD1_MICRONAS = 0x0105, /* 261 */146};147enum blackbird_field2_lines {148BLACKBIRD_FIELD2_SAA7114 = 0x00EF, /* 239 */149BLACKBIRD_FIELD2_SAA7115 = 0x00F0, /* 240 */150BLACKBIRD_FIELD2_MICRONAS = 0x0106, /* 262 */151};152enum blackbird_custom_data_type {153BLACKBIRD_CUSTOM_EXTENSION_USR_DATA,154BLACKBIRD_CUSTOM_PRIVATE_PACKET,155};156enum blackbird_mute {157BLACKBIRD_UNMUTE,158BLACKBIRD_MUTE,159};160enum blackbird_mute_video_mask {161BLACKBIRD_MUTE_VIDEO_V_MASK = 0x0000FF00,162BLACKBIRD_MUTE_VIDEO_U_MASK = 0x00FF0000,163BLACKBIRD_MUTE_VIDEO_Y_MASK = 0xFF000000,164};165enum blackbird_mute_video_shift {166BLACKBIRD_MUTE_VIDEO_V_SHIFT = 8,167BLACKBIRD_MUTE_VIDEO_U_SHIFT = 16,168BLACKBIRD_MUTE_VIDEO_Y_SHIFT = 24,169};170171/* Registers */172#define IVTV_REG_ENC_SDRAM_REFRESH (0x07F8 /*| IVTV_REG_OFFSET*/)173#define IVTV_REG_ENC_SDRAM_PRECHARGE (0x07FC /*| IVTV_REG_OFFSET*/)174#define IVTV_REG_SPU (0x9050 /*| IVTV_REG_OFFSET*/)175#define IVTV_REG_HW_BLOCKS (0x9054 /*| IVTV_REG_OFFSET*/)176#define IVTV_REG_VPU (0x9058 /*| IVTV_REG_OFFSET*/)177#define IVTV_REG_APU (0xA064 /*| IVTV_REG_OFFSET*/)178179/* ------------------------------------------------------------------ */180181static void host_setup(struct cx88_core *core)182{183/* toggle reset of the host */184cx_write(MO_GPHST_SOFT_RST, 1);185udelay(100);186cx_write(MO_GPHST_SOFT_RST, 0);187udelay(100);188189/* host port setup */190cx_write(MO_GPHST_WSC, 0x44444444U);191cx_write(MO_GPHST_XFR, 0);192cx_write(MO_GPHST_WDTH, 15);193cx_write(MO_GPHST_HDSHK, 0);194cx_write(MO_GPHST_MUX16, 0x44448888U);195cx_write(MO_GPHST_MODE, 0);196}197198/* ------------------------------------------------------------------ */199200#define P1_MDATA0 0x390000201#define P1_MDATA1 0x390001202#define P1_MDATA2 0x390002203#define P1_MDATA3 0x390003204#define P1_MADDR2 0x390004205#define P1_MADDR1 0x390005206#define P1_MADDR0 0x390006207#define P1_RDATA0 0x390008208#define P1_RDATA1 0x390009209#define P1_RDATA2 0x39000A210#define P1_RDATA3 0x39000B211#define P1_RADDR0 0x39000C212#define P1_RADDR1 0x39000D213#define P1_RRDWR 0x39000E214215static int wait_ready_gpio0_bit1(struct cx88_core *core, u32 state)216{217unsigned long timeout = jiffies + msecs_to_jiffies(1);218u32 gpio0,need;219220need = state ? 2 : 0;221for (;;) {222gpio0 = cx_read(MO_GP0_IO) & 2;223if (need == gpio0)224return 0;225if (time_after(jiffies,timeout))226return -1;227udelay(1);228}229}230231static int memory_write(struct cx88_core *core, u32 address, u32 value)232{233/* Warning: address is dword address (4 bytes) */234cx_writeb(P1_MDATA0, (unsigned int)value);235cx_writeb(P1_MDATA1, (unsigned int)(value >> 8));236cx_writeb(P1_MDATA2, (unsigned int)(value >> 16));237cx_writeb(P1_MDATA3, (unsigned int)(value >> 24));238cx_writeb(P1_MADDR2, (unsigned int)(address >> 16) | 0x40);239cx_writeb(P1_MADDR1, (unsigned int)(address >> 8));240cx_writeb(P1_MADDR0, (unsigned int)address);241cx_read(P1_MDATA0);242cx_read(P1_MADDR0);243244return wait_ready_gpio0_bit1(core,1);245}246247static int memory_read(struct cx88_core *core, u32 address, u32 *value)248{249int retval;250u32 val;251252/* Warning: address is dword address (4 bytes) */253cx_writeb(P1_MADDR2, (unsigned int)(address >> 16) & ~0xC0);254cx_writeb(P1_MADDR1, (unsigned int)(address >> 8));255cx_writeb(P1_MADDR0, (unsigned int)address);256cx_read(P1_MADDR0);257258retval = wait_ready_gpio0_bit1(core,1);259260cx_writeb(P1_MDATA3, 0);261val = (unsigned char)cx_read(P1_MDATA3) << 24;262cx_writeb(P1_MDATA2, 0);263val |= (unsigned char)cx_read(P1_MDATA2) << 16;264cx_writeb(P1_MDATA1, 0);265val |= (unsigned char)cx_read(P1_MDATA1) << 8;266cx_writeb(P1_MDATA0, 0);267val |= (unsigned char)cx_read(P1_MDATA0);268269*value = val;270return retval;271}272273static int register_write(struct cx88_core *core, u32 address, u32 value)274{275cx_writeb(P1_RDATA0, (unsigned int)value);276cx_writeb(P1_RDATA1, (unsigned int)(value >> 8));277cx_writeb(P1_RDATA2, (unsigned int)(value >> 16));278cx_writeb(P1_RDATA3, (unsigned int)(value >> 24));279cx_writeb(P1_RADDR0, (unsigned int)address);280cx_writeb(P1_RADDR1, (unsigned int)(address >> 8));281cx_writeb(P1_RRDWR, 1);282cx_read(P1_RDATA0);283cx_read(P1_RADDR0);284285return wait_ready_gpio0_bit1(core,1);286}287288289static int register_read(struct cx88_core *core, u32 address, u32 *value)290{291int retval;292u32 val;293294cx_writeb(P1_RADDR0, (unsigned int)address);295cx_writeb(P1_RADDR1, (unsigned int)(address >> 8));296cx_writeb(P1_RRDWR, 0);297cx_read(P1_RADDR0);298299retval = wait_ready_gpio0_bit1(core,1);300val = (unsigned char)cx_read(P1_RDATA0);301val |= (unsigned char)cx_read(P1_RDATA1) << 8;302val |= (unsigned char)cx_read(P1_RDATA2) << 16;303val |= (unsigned char)cx_read(P1_RDATA3) << 24;304305*value = val;306return retval;307}308309/* ------------------------------------------------------------------ */310311static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 data[CX2341X_MBOX_MAX_DATA])312{313struct cx8802_dev *dev = priv;314unsigned long timeout;315u32 value, flag, retval;316int i;317318dprintk(1,"%s: 0x%X\n", __func__, command);319320/* this may not be 100% safe if we can't read any memory location321without side effects */322memory_read(dev->core, dev->mailbox - 4, &value);323if (value != 0x12345678) {324dprintk(0, "Firmware and/or mailbox pointer not initialized or corrupted\n");325return -1;326}327328memory_read(dev->core, dev->mailbox, &flag);329if (flag) {330dprintk(0, "ERROR: Mailbox appears to be in use (%x)\n", flag);331return -1;332}333334flag |= 1; /* tell 'em we're working on it */335memory_write(dev->core, dev->mailbox, flag);336337/* write command + args + fill remaining with zeros */338memory_write(dev->core, dev->mailbox + 1, command); /* command code */339memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT); /* timeout */340for (i = 0; i < in; i++) {341memory_write(dev->core, dev->mailbox + 4 + i, data[i]);342dprintk(1, "API Input %d = %d\n", i, data[i]);343}344for (; i < CX2341X_MBOX_MAX_DATA; i++)345memory_write(dev->core, dev->mailbox + 4 + i, 0);346347flag |= 3; /* tell 'em we're done writing */348memory_write(dev->core, dev->mailbox, flag);349350/* wait for firmware to handle the API command */351timeout = jiffies + msecs_to_jiffies(10);352for (;;) {353memory_read(dev->core, dev->mailbox, &flag);354if (0 != (flag & 4))355break;356if (time_after(jiffies,timeout)) {357dprintk(0, "ERROR: API Mailbox timeout\n");358return -1;359}360udelay(10);361}362363/* read output values */364for (i = 0; i < out; i++) {365memory_read(dev->core, dev->mailbox + 4 + i, data + i);366dprintk(1, "API Output %d = %d\n", i, data[i]);367}368369memory_read(dev->core, dev->mailbox + 2, &retval);370dprintk(1, "API result = %d\n",retval);371372flag = 0;373memory_write(dev->core, dev->mailbox, flag);374return retval;375}376/* ------------------------------------------------------------------ */377378/* We don't need to call the API often, so using just one mailbox will probably suffice */379static int blackbird_api_cmd(struct cx8802_dev *dev, u32 command,380u32 inputcnt, u32 outputcnt, ...)381{382u32 data[CX2341X_MBOX_MAX_DATA];383va_list vargs;384int i, err;385386va_start(vargs, outputcnt);387388for (i = 0; i < inputcnt; i++) {389data[i] = va_arg(vargs, int);390}391err = blackbird_mbox_func(dev, command, inputcnt, outputcnt, data);392for (i = 0; i < outputcnt; i++) {393int *vptr = va_arg(vargs, int *);394*vptr = data[i];395}396va_end(vargs);397return err;398}399400static int blackbird_find_mailbox(struct cx8802_dev *dev)401{402u32 signature[4]={0x12345678, 0x34567812, 0x56781234, 0x78123456};403int signaturecnt=0;404u32 value;405int i;406407for (i = 0; i < BLACKBIRD_FIRM_IMAGE_SIZE; i++) {408memory_read(dev->core, i, &value);409if (value == signature[signaturecnt])410signaturecnt++;411else412signaturecnt = 0;413if (4 == signaturecnt) {414dprintk(1, "Mailbox signature found\n");415return i+1;416}417}418dprintk(0, "Mailbox signature values not found!\n");419return -1;420}421422static int blackbird_load_firmware(struct cx8802_dev *dev)423{424static const unsigned char magic[8] = {4250xa7, 0x0d, 0x00, 0x00, 0x66, 0xbb, 0x55, 0xaa426};427const struct firmware *firmware;428int i, retval = 0;429u32 value = 0;430u32 checksum = 0;431u32 *dataptr;432433retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED);434retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST);435retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH, 0x80000640);436retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE, 0x1A);437msleep(1);438retval |= register_write(dev->core, IVTV_REG_APU, 0);439440if (retval < 0)441dprintk(0, "Error with register_write\n");442443retval = request_firmware(&firmware, CX2341X_FIRM_ENC_FILENAME,444&dev->pci->dev);445446447if (retval != 0) {448dprintk(0, "ERROR: Hotplug firmware request failed (%s).\n",449CX2341X_FIRM_ENC_FILENAME);450dprintk(0, "Please fix your hotplug setup, the board will "451"not work without firmware loaded!\n");452return -1;453}454455if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) {456dprintk(0, "ERROR: Firmware size mismatch (have %zd, expected %d)\n",457firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE);458release_firmware(firmware);459return -1;460}461462if (0 != memcmp(firmware->data, magic, 8)) {463dprintk(0, "ERROR: Firmware magic mismatch, wrong file?\n");464release_firmware(firmware);465return -1;466}467468/* transfer to the chip */469dprintk(1,"Loading firmware ...\n");470dataptr = (u32*)firmware->data;471for (i = 0; i < (firmware->size >> 2); i++) {472value = *dataptr;473checksum += ~value;474memory_write(dev->core, i, value);475dataptr++;476}477478/* read back to verify with the checksum */479for (i--; i >= 0; i--) {480memory_read(dev->core, i, &value);481checksum -= ~value;482}483if (checksum) {484dprintk(0, "ERROR: Firmware load failed (checksum mismatch).\n");485release_firmware(firmware);486return -1;487}488release_firmware(firmware);489dprintk(0, "Firmware upload successful.\n");490491retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST);492retval |= register_read(dev->core, IVTV_REG_SPU, &value);493retval |= register_write(dev->core, IVTV_REG_SPU, value & 0xFFFFFFFE);494msleep(1);495496retval |= register_read(dev->core, IVTV_REG_VPU, &value);497retval |= register_write(dev->core, IVTV_REG_VPU, value & 0xFFFFFFE8);498499if (retval < 0)500dprintk(0, "Error with register_write\n");501return 0;502}503504/**505Settings used by the windows tv app for PVR2000:506=================================================================================================================507Profile | Codec | Resolution | CBR/VBR | Video Qlty | V. Bitrate | Frmrate | Audio Codec | A. Bitrate | A. Mode508-----------------------------------------------------------------------------------------------------------------509MPEG-1 | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 2000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo510MPEG-2 | MPEG2 | 720x576PAL | VBR | 600 :Good | 4000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo511VCD | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 1150 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo512DVD | MPEG2 | 720x576PAL | VBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo513DB* DVD | MPEG2 | 720x576PAL | CBR | 600 :Good | 6000 Kbps | 25fps | MPG1 Layer2 | 224kbps | Stereo514=================================================================================================================515*DB: "DirectBurn"516*/517518static void blackbird_codec_settings(struct cx8802_dev *dev)519{520/* assign frame size */521blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0,522dev->height, dev->width);523524dev->params.width = dev->width;525dev->params.height = dev->height;526dev->params.is_50hz = (dev->core->tvnorm & V4L2_STD_625_50) != 0;527528cx2341x_update(dev, blackbird_mbox_func, NULL, &dev->params);529}530531static int blackbird_initialize_codec(struct cx8802_dev *dev)532{533struct cx88_core *core = dev->core;534int version;535int retval;536537dprintk(1,"Initialize codec\n");538retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */539if (retval < 0) {540541dev->mpeg_active = 0;542543/* ping was not successful, reset and upload firmware */544cx_write(MO_SRST_IO, 0); /* SYS_RSTO=0 */545cx_write(MO_SRST_IO, 1); /* SYS_RSTO=1 */546retval = blackbird_load_firmware(dev);547if (retval < 0)548return retval;549550retval = blackbird_find_mailbox(dev);551if (retval < 0)552return -1;553554dev->mailbox = retval;555556retval = blackbird_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */557if (retval < 0) {558dprintk(0, "ERROR: Firmware ping failed!\n");559return -1;560}561562retval = blackbird_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, &version);563if (retval < 0) {564dprintk(0, "ERROR: Firmware get encoder version failed!\n");565return -1;566}567dprintk(0, "Firmware version is 0x%08x\n", version);568}569570cx_write(MO_PINMUX_IO, 0x88); /* 656-8bit IO and enable MPEG parallel IO */571cx_clear(MO_INPUT_FORMAT, 0x100); /* chroma subcarrier lock to normal? */572cx_write(MO_VBOS_CONTROL, 0x84A00); /* no 656 mode, 8-bit pixels, disable VBI */573cx_clear(MO_OUTPUT_FORMAT, 0x0008); /* Normal Y-limits to let the mpeg encoder sync */574575blackbird_codec_settings(dev);576577blackbird_api_cmd(dev, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 0,578BLACKBIRD_FIELD1_SAA7115,579BLACKBIRD_FIELD2_SAA7115580);581582blackbird_api_cmd(dev, CX2341X_ENC_SET_PLACEHOLDER, 12, 0,583BLACKBIRD_CUSTOM_EXTENSION_USR_DATA,5840, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);585586return 0;587}588589static int blackbird_start_codec(struct file *file, void *priv)590{591struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev;592struct cx88_core *core = dev->core;593/* start capturing to the host interface */594u32 reg;595596int i;597int lastchange = -1;598int lastval = 0;599600for (i = 0; (i < 10) && (i < (lastchange + 4)); i++) {601reg = cx_read(AUD_STATUS);602603dprintk(1, "AUD_STATUS:%dL: 0x%x\n", i, reg);604if ((reg & 0x0F) != lastval) {605lastval = reg & 0x0F;606lastchange = i;607}608msleep(100);609}610611/* unmute audio source */612cx_clear(AUD_VOL_CTL, (1 << 6));613614blackbird_api_cmd(dev, CX2341X_ENC_REFRESH_INPUT, 0, 0);615616/* initialize the video input */617blackbird_api_cmd(dev, CX2341X_ENC_INITIALIZE_INPUT, 0, 0);618619/* start capturing to the host interface */620blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0,621BLACKBIRD_MPEG_CAPTURE,622BLACKBIRD_RAW_BITS_NONE623);624625dev->mpeg_active = 1;626return 0;627}628629static int blackbird_stop_codec(struct cx8802_dev *dev)630{631blackbird_api_cmd(dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,632BLACKBIRD_END_NOW,633BLACKBIRD_MPEG_CAPTURE,634BLACKBIRD_RAW_BITS_NONE635);636637dev->mpeg_active = 0;638return 0;639}640641/* ------------------------------------------------------------------ */642643static int bb_buf_setup(struct videobuf_queue *q,644unsigned int *count, unsigned int *size)645{646struct cx8802_fh *fh = q->priv_data;647648fh->dev->ts_packet_size = 188 * 4; /* was: 512 */649fh->dev->ts_packet_count = mpegbufs; /* was: 100 */650651*size = fh->dev->ts_packet_size * fh->dev->ts_packet_count;652*count = fh->dev->ts_packet_count;653return 0;654}655656static int657bb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,658enum v4l2_field field)659{660struct cx8802_fh *fh = q->priv_data;661return cx8802_buf_prepare(q, fh->dev, (struct cx88_buffer*)vb, field);662}663664static void665bb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)666{667struct cx8802_fh *fh = q->priv_data;668cx8802_buf_queue(fh->dev, (struct cx88_buffer*)vb);669}670671static void672bb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)673{674cx88_free_buffer(q, (struct cx88_buffer*)vb);675}676677static struct videobuf_queue_ops blackbird_qops = {678.buf_setup = bb_buf_setup,679.buf_prepare = bb_buf_prepare,680.buf_queue = bb_buf_queue,681.buf_release = bb_buf_release,682};683684/* ------------------------------------------------------------------ */685686static const u32 *ctrl_classes[] = {687cx88_user_ctrls,688cx2341x_mpeg_ctrls,689NULL690};691692static int blackbird_queryctrl(struct cx8802_dev *dev, struct v4l2_queryctrl *qctrl)693{694qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);695if (qctrl->id == 0)696return -EINVAL;697698/* Standard V4L2 controls */699if (cx8800_ctrl_query(dev->core, qctrl) == 0)700return 0;701702/* MPEG V4L2 controls */703if (cx2341x_ctrl_query(&dev->params, qctrl))704qctrl->flags |= V4L2_CTRL_FLAG_DISABLED;705return 0;706}707708/* ------------------------------------------------------------------ */709/* IOCTL Handlers */710711static int vidioc_querymenu (struct file *file, void *priv,712struct v4l2_querymenu *qmenu)713{714struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev;715struct v4l2_queryctrl qctrl;716717qctrl.id = qmenu->id;718blackbird_queryctrl(dev, &qctrl);719return v4l2_ctrl_query_menu(qmenu, &qctrl,720cx2341x_ctrl_get_menu(&dev->params, qmenu->id));721}722723static int vidioc_querycap (struct file *file, void *priv,724struct v4l2_capability *cap)725{726struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev;727struct cx88_core *core = dev->core;728729strcpy(cap->driver, "cx88_blackbird");730strlcpy(cap->card, core->board.name, sizeof(cap->card));731sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci));732cap->version = CX88_VERSION_CODE;733cap->capabilities =734V4L2_CAP_VIDEO_CAPTURE |735V4L2_CAP_READWRITE |736V4L2_CAP_STREAMING;737if (UNSET != core->board.tuner_type)738cap->capabilities |= V4L2_CAP_TUNER;739return 0;740}741742static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv,743struct v4l2_fmtdesc *f)744{745if (f->index != 0)746return -EINVAL;747748strlcpy(f->description, "MPEG", sizeof(f->description));749f->pixelformat = V4L2_PIX_FMT_MPEG;750return 0;751}752753static int vidioc_g_fmt_vid_cap (struct file *file, void *priv,754struct v4l2_format *f)755{756struct cx8802_fh *fh = priv;757struct cx8802_dev *dev = fh->dev;758759f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;760f->fmt.pix.bytesperline = 0;761f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */762f->fmt.pix.colorspace = 0;763f->fmt.pix.width = dev->width;764f->fmt.pix.height = dev->height;765f->fmt.pix.field = fh->mpegq.field;766dprintk(0,"VIDIOC_G_FMT: w: %d, h: %d, f: %d\n",767dev->width, dev->height, fh->mpegq.field );768return 0;769}770771static int vidioc_try_fmt_vid_cap (struct file *file, void *priv,772struct v4l2_format *f)773{774struct cx8802_fh *fh = priv;775struct cx8802_dev *dev = fh->dev;776777f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;778f->fmt.pix.bytesperline = 0;779f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */;780f->fmt.pix.colorspace = 0;781dprintk(0,"VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n",782dev->width, dev->height, fh->mpegq.field );783return 0;784}785786static int vidioc_s_fmt_vid_cap (struct file *file, void *priv,787struct v4l2_format *f)788{789struct cx8802_fh *fh = priv;790struct cx8802_dev *dev = fh->dev;791struct cx88_core *core = dev->core;792793f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;794f->fmt.pix.bytesperline = 0;795f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */;796f->fmt.pix.colorspace = 0;797dev->width = f->fmt.pix.width;798dev->height = f->fmt.pix.height;799fh->mpegq.field = f->fmt.pix.field;800cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field);801blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0,802f->fmt.pix.height, f->fmt.pix.width);803dprintk(0,"VIDIOC_S_FMT: w: %d, h: %d, f: %d\n",804f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field );805return 0;806}807808static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p)809{810struct cx8802_fh *fh = priv;811return (videobuf_reqbufs(&fh->mpegq, p));812}813814static int vidioc_querybuf (struct file *file, void *priv, struct v4l2_buffer *p)815{816struct cx8802_fh *fh = priv;817return (videobuf_querybuf(&fh->mpegq, p));818}819820static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *p)821{822struct cx8802_fh *fh = priv;823return (videobuf_qbuf(&fh->mpegq, p));824}825826static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p)827{828struct cx8802_fh *fh = priv;829return (videobuf_dqbuf(&fh->mpegq, p,830file->f_flags & O_NONBLOCK));831}832833static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)834{835struct cx8802_fh *fh = priv;836return videobuf_streamon(&fh->mpegq);837}838839static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)840{841struct cx8802_fh *fh = priv;842return videobuf_streamoff(&fh->mpegq);843}844845static int vidioc_g_ext_ctrls (struct file *file, void *priv,846struct v4l2_ext_controls *f)847{848struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev;849850if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)851return -EINVAL;852return cx2341x_ext_ctrls(&dev->params, 0, f, VIDIOC_G_EXT_CTRLS);853}854855static int vidioc_s_ext_ctrls (struct file *file, void *priv,856struct v4l2_ext_controls *f)857{858struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev;859struct cx2341x_mpeg_params p;860int err;861862if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)863return -EINVAL;864865if (dev->mpeg_active)866blackbird_stop_codec(dev);867868p = dev->params;869err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_S_EXT_CTRLS);870if (!err) {871err = cx2341x_update(dev, blackbird_mbox_func, &dev->params, &p);872dev->params = p;873}874return err;875}876877static int vidioc_try_ext_ctrls (struct file *file, void *priv,878struct v4l2_ext_controls *f)879{880struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev;881struct cx2341x_mpeg_params p;882int err;883884if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)885return -EINVAL;886p = dev->params;887err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_TRY_EXT_CTRLS);888889return err;890}891892static int vidioc_s_frequency (struct file *file, void *priv,893struct v4l2_frequency *f)894{895struct cx8802_fh *fh = priv;896struct cx8802_dev *dev = fh->dev;897struct cx88_core *core = dev->core;898899if (dev->mpeg_active)900blackbird_stop_codec(dev);901902cx88_set_freq (core,f);903blackbird_initialize_codec(dev);904cx88_set_scale(dev->core, dev->width, dev->height,905fh->mpegq.field);906return 0;907}908909static int vidioc_log_status (struct file *file, void *priv)910{911struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev;912struct cx88_core *core = dev->core;913char name[32 + 2];914915snprintf(name, sizeof(name), "%s/2", core->name);916printk("%s/2: ============ START LOG STATUS ============\n",917core->name);918call_all(core, core, log_status);919cx2341x_log_status(&dev->params, name);920printk("%s/2: ============= END LOG STATUS =============\n",921core->name);922return 0;923}924925static int vidioc_queryctrl (struct file *file, void *priv,926struct v4l2_queryctrl *qctrl)927{928struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev;929930if (blackbird_queryctrl(dev, qctrl) == 0)931return 0;932933qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);934if (unlikely(qctrl->id == 0))935return -EINVAL;936return cx8800_ctrl_query(dev->core, qctrl);937}938939static int vidioc_enum_input (struct file *file, void *priv,940struct v4l2_input *i)941{942struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core;943return cx88_enum_input (core,i);944}945946static int vidioc_g_ctrl (struct file *file, void *priv,947struct v4l2_control *ctl)948{949struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core;950return951cx88_get_control(core,ctl);952}953954static int vidioc_s_ctrl (struct file *file, void *priv,955struct v4l2_control *ctl)956{957struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core;958return959cx88_set_control(core,ctl);960}961962static int vidioc_g_frequency (struct file *file, void *priv,963struct v4l2_frequency *f)964{965struct cx8802_fh *fh = priv;966struct cx88_core *core = fh->dev->core;967968if (unlikely(UNSET == core->board.tuner_type))969return -EINVAL;970971f->type = V4L2_TUNER_ANALOG_TV;972f->frequency = core->freq;973call_all(core, tuner, g_frequency, f);974975return 0;976}977978static int vidioc_g_input (struct file *file, void *priv, unsigned int *i)979{980struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core;981982*i = core->input;983return 0;984}985986static int vidioc_s_input (struct file *file, void *priv, unsigned int i)987{988struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core;989990if (i >= 4)991return -EINVAL;992993mutex_lock(&core->lock);994cx88_newstation(core);995cx88_video_mux(core,i);996mutex_unlock(&core->lock);997return 0;998}9991000static int vidioc_g_tuner (struct file *file, void *priv,1001struct v4l2_tuner *t)1002{1003struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core;1004u32 reg;10051006if (unlikely(UNSET == core->board.tuner_type))1007return -EINVAL;1008if (0 != t->index)1009return -EINVAL;10101011strcpy(t->name, "Television");1012t->type = V4L2_TUNER_ANALOG_TV;1013t->capability = V4L2_TUNER_CAP_NORM;1014t->rangehigh = 0xffffffffUL;10151016cx88_get_stereo(core ,t);1017reg = cx_read(MO_DEVICE_STATUS);1018t->signal = (reg & (1<<5)) ? 0xffff : 0x0000;1019return 0;1020}10211022static int vidioc_s_tuner (struct file *file, void *priv,1023struct v4l2_tuner *t)1024{1025struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core;10261027if (UNSET == core->board.tuner_type)1028return -EINVAL;1029if (0 != t->index)1030return -EINVAL;10311032cx88_set_stereo(core, t->audmode, 1);1033return 0;1034}10351036static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id)1037{1038struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core;10391040mutex_lock(&core->lock);1041cx88_set_tvnorm(core,*id);1042mutex_unlock(&core->lock);1043return 0;1044}10451046/* FIXME: cx88_ioctl_hook not implemented */10471048static int mpeg_open(struct file *file)1049{1050struct video_device *vdev = video_devdata(file);1051struct cx8802_dev *dev = video_drvdata(file);1052struct cx8802_fh *fh;1053struct cx8802_driver *drv = NULL;1054int err;10551056dprintk( 1, "%s\n", __func__);10571058mutex_lock(&dev->core->lock);10591060/* Make sure we can acquire the hardware */1061drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);1062if (!drv) {1063dprintk(1, "%s: blackbird driver is not loaded\n", __func__);1064mutex_unlock(&dev->core->lock);1065return -ENODEV;1066}10671068err = drv->request_acquire(drv);1069if (err != 0) {1070dprintk(1,"%s: Unable to acquire hardware, %d\n", __func__, err);1071mutex_unlock(&dev->core->lock);1072return err;1073}10741075if (!dev->core->mpeg_users && blackbird_initialize_codec(dev) < 0) {1076drv->request_release(drv);1077mutex_unlock(&dev->core->lock);1078return -EINVAL;1079}1080dprintk(1, "open dev=%s\n", video_device_node_name(vdev));10811082/* allocate + initialize per filehandle data */1083fh = kzalloc(sizeof(*fh),GFP_KERNEL);1084if (NULL == fh) {1085drv->request_release(drv);1086mutex_unlock(&dev->core->lock);1087return -ENOMEM;1088}1089file->private_data = fh;1090fh->dev = dev;10911092videobuf_queue_sg_init(&fh->mpegq, &blackbird_qops,1093&dev->pci->dev, &dev->slock,1094V4L2_BUF_TYPE_VIDEO_CAPTURE,1095V4L2_FIELD_INTERLACED,1096sizeof(struct cx88_buffer),1097fh, NULL);10981099/* FIXME: locking against other video device */1100cx88_set_scale(dev->core, dev->width, dev->height,1101fh->mpegq.field);11021103dev->core->mpeg_users++;1104mutex_unlock(&dev->core->lock);1105return 0;1106}11071108static int mpeg_release(struct file *file)1109{1110struct cx8802_fh *fh = file->private_data;1111struct cx8802_dev *dev = fh->dev;1112struct cx8802_driver *drv = NULL;11131114mutex_lock(&dev->core->lock);11151116if (dev->mpeg_active && dev->core->mpeg_users == 1)1117blackbird_stop_codec(dev);11181119cx8802_cancel_buffers(fh->dev);1120/* stop mpeg capture */1121videobuf_stop(&fh->mpegq);11221123videobuf_mmap_free(&fh->mpegq);11241125file->private_data = NULL;1126kfree(fh);11271128/* Make sure we release the hardware */1129drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);1130WARN_ON(!drv);1131if (drv)1132drv->request_release(drv);11331134dev->core->mpeg_users--;11351136mutex_unlock(&dev->core->lock);11371138return 0;1139}11401141static ssize_t1142mpeg_read(struct file *file, char __user *data, size_t count, loff_t *ppos)1143{1144struct cx8802_fh *fh = file->private_data;1145struct cx8802_dev *dev = fh->dev;11461147if (!dev->mpeg_active)1148blackbird_start_codec(file, fh);11491150return videobuf_read_stream(&fh->mpegq, data, count, ppos, 0,1151file->f_flags & O_NONBLOCK);1152}11531154static unsigned int1155mpeg_poll(struct file *file, struct poll_table_struct *wait)1156{1157struct cx8802_fh *fh = file->private_data;1158struct cx8802_dev *dev = fh->dev;11591160if (!dev->mpeg_active)1161blackbird_start_codec(file, fh);11621163return videobuf_poll_stream(file, &fh->mpegq, wait);1164}11651166static int1167mpeg_mmap(struct file *file, struct vm_area_struct * vma)1168{1169struct cx8802_fh *fh = file->private_data;11701171return videobuf_mmap_mapper(&fh->mpegq, vma);1172}11731174static const struct v4l2_file_operations mpeg_fops =1175{1176.owner = THIS_MODULE,1177.open = mpeg_open,1178.release = mpeg_release,1179.read = mpeg_read,1180.poll = mpeg_poll,1181.mmap = mpeg_mmap,1182.ioctl = video_ioctl2,1183};11841185static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {1186.vidioc_querymenu = vidioc_querymenu,1187.vidioc_querycap = vidioc_querycap,1188.vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,1189.vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,1190.vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap,1191.vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap,1192.vidioc_reqbufs = vidioc_reqbufs,1193.vidioc_querybuf = vidioc_querybuf,1194.vidioc_qbuf = vidioc_qbuf,1195.vidioc_dqbuf = vidioc_dqbuf,1196.vidioc_streamon = vidioc_streamon,1197.vidioc_streamoff = vidioc_streamoff,1198.vidioc_g_ext_ctrls = vidioc_g_ext_ctrls,1199.vidioc_s_ext_ctrls = vidioc_s_ext_ctrls,1200.vidioc_try_ext_ctrls = vidioc_try_ext_ctrls,1201.vidioc_s_frequency = vidioc_s_frequency,1202.vidioc_log_status = vidioc_log_status,1203.vidioc_queryctrl = vidioc_queryctrl,1204.vidioc_enum_input = vidioc_enum_input,1205.vidioc_g_ctrl = vidioc_g_ctrl,1206.vidioc_s_ctrl = vidioc_s_ctrl,1207.vidioc_g_frequency = vidioc_g_frequency,1208.vidioc_g_input = vidioc_g_input,1209.vidioc_s_input = vidioc_s_input,1210.vidioc_g_tuner = vidioc_g_tuner,1211.vidioc_s_tuner = vidioc_s_tuner,1212.vidioc_s_std = vidioc_s_std,1213};12141215static struct video_device cx8802_mpeg_template = {1216.name = "cx8802",1217.fops = &mpeg_fops,1218.ioctl_ops = &mpeg_ioctl_ops,1219.tvnorms = CX88_NORMS,1220.current_norm = V4L2_STD_NTSC_M,1221};12221223/* ------------------------------------------------------------------ */12241225/* The CX8802 MPEG API will call this when we can use the hardware */1226static int cx8802_blackbird_advise_acquire(struct cx8802_driver *drv)1227{1228struct cx88_core *core = drv->core;1229int err = 0;12301231switch (core->boardnr) {1232case CX88_BOARD_HAUPPAUGE_HVR1300:1233/* By default, core setup will leave the cx22702 out of reset, on the bus.1234* We left the hardware on power up with the cx22702 active.1235* We're being given access to re-arrange the GPIOs.1236* Take the bus off the cx22702 and put the cx23416 on it.1237*/1238/* Toggle reset on cx22702 leaving i2c active */1239cx_set(MO_GP0_IO, 0x00000080);1240udelay(1000);1241cx_clear(MO_GP0_IO, 0x00000080);1242udelay(50);1243cx_set(MO_GP0_IO, 0x00000080);1244udelay(1000);1245/* tri-state the cx22702 pins */1246cx_set(MO_GP0_IO, 0x00000004);1247udelay(1000);1248break;1249default:1250err = -ENODEV;1251}1252return err;1253}12541255/* The CX8802 MPEG API will call this when we need to release the hardware */1256static int cx8802_blackbird_advise_release(struct cx8802_driver *drv)1257{1258struct cx88_core *core = drv->core;1259int err = 0;12601261switch (core->boardnr) {1262case CX88_BOARD_HAUPPAUGE_HVR1300:1263/* Exit leaving the cx23416 on the bus */1264break;1265default:1266err = -ENODEV;1267}1268return err;1269}12701271static void blackbird_unregister_video(struct cx8802_dev *dev)1272{1273if (dev->mpeg_dev) {1274if (video_is_registered(dev->mpeg_dev))1275video_unregister_device(dev->mpeg_dev);1276else1277video_device_release(dev->mpeg_dev);1278dev->mpeg_dev = NULL;1279}1280}12811282static int blackbird_register_video(struct cx8802_dev *dev)1283{1284int err;12851286dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci,1287&cx8802_mpeg_template,"mpeg");1288video_set_drvdata(dev->mpeg_dev, dev);1289err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1);1290if (err < 0) {1291printk(KERN_INFO "%s/2: can't register mpeg device\n",1292dev->core->name);1293return err;1294}1295printk(KERN_INFO "%s/2: registered device %s [mpeg]\n",1296dev->core->name, video_device_node_name(dev->mpeg_dev));1297return 0;1298}12991300/* ----------------------------------------------------------- */13011302static int cx8802_blackbird_probe(struct cx8802_driver *drv)1303{1304struct cx88_core *core = drv->core;1305struct cx8802_dev *dev = core->dvbdev;1306int err;13071308dprintk( 1, "%s\n", __func__);1309dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",1310core->boardnr,1311core->name,1312core->pci_bus,1313core->pci_slot);13141315err = -ENODEV;1316if (!(core->board.mpeg & CX88_MPEG_BLACKBIRD))1317goto fail_core;13181319dev->width = 720;1320dev->height = 576;1321cx2341x_fill_defaults(&dev->params);1322dev->params.port = CX2341X_PORT_STREAMING;13231324cx8802_mpeg_template.current_norm = core->tvnorm;13251326if (core->tvnorm & V4L2_STD_525_60) {1327dev->height = 480;1328} else {1329dev->height = 576;1330}13311332/* blackbird stuff */1333printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n",1334core->name);1335host_setup(dev->core);13361337blackbird_initialize_codec(dev);1338blackbird_register_video(dev);13391340/* initial device configuration: needed ? */1341// init_controls(core);1342cx88_set_tvnorm(core,core->tvnorm);1343cx88_video_mux(core,0);13441345return 0;13461347fail_core:1348return err;1349}13501351static int cx8802_blackbird_remove(struct cx8802_driver *drv)1352{1353/* blackbird */1354blackbird_unregister_video(drv->core->dvbdev);13551356return 0;1357}13581359static struct cx8802_driver cx8802_blackbird_driver = {1360.type_id = CX88_MPEG_BLACKBIRD,1361.hw_access = CX8802_DRVCTL_SHARED,1362.probe = cx8802_blackbird_probe,1363.remove = cx8802_blackbird_remove,1364.advise_acquire = cx8802_blackbird_advise_acquire,1365.advise_release = cx8802_blackbird_advise_release,1366};13671368static int __init blackbird_init(void)1369{1370printk(KERN_INFO "cx2388x blackbird driver version %d.%d.%d loaded\n",1371(CX88_VERSION_CODE >> 16) & 0xff,1372(CX88_VERSION_CODE >> 8) & 0xff,1373CX88_VERSION_CODE & 0xff);1374#ifdef SNAPSHOT1375printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",1376SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);1377#endif1378return cx8802_register_driver(&cx8802_blackbird_driver);1379}13801381static void __exit blackbird_fini(void)1382{1383cx8802_unregister_driver(&cx8802_blackbird_driver);1384}13851386module_init(blackbird_init);1387module_exit(blackbird_fini);13881389module_param_named(video_debug,cx8802_mpeg_template.debug, int, 0644);1390MODULE_PARM_DESC(debug,"enable debug messages [video]");13911392/* ----------------------------------------------------------- */1393/*1394* Local variables:1395* c-basic-offset: 81396* End:1397* kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off1398*/139914001401