/*
* $Id: cx88-blackbird.c,v 1.27 2005/06/03 13:31:50 mchehab Exp $
*
* Support for a cx23416 mpeg encoder via cx2388x host port.
* "blackbird" reference design.
*
* (c) 2004 Jelle Foks <jelle@foks.8m.com>
* (c) 2004 Gerd Knorr <kraxel@bytesex.org>
*
* Includes parts from the ivtv driver( http://ivtv.sourceforge.net/),
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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 <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/firmware.h>
#include "cx88.h"
MODULE_DESCRIPTION("driver for cx2388x/cx23416 based mpeg encoder cards");
MODULE_AUTHOR("Jelle Foks <jelle@foks.8m.com>");
MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
MODULE_LICENSE("GPL");
static unsigned int mpegbufs = 8;
module_param(mpegbufs,int,0644);
MODULE_PARM_DESC(mpegbufs,"number of mpeg buffers, range 2-32");
static unsigned int debug = 0;
module_param(debug,int,0644);
MODULE_PARM_DESC(debug,"enable debug messages [blackbird]");
#define dprintk(level,fmt, arg...) if (debug >= level) \
printk(KERN_DEBUG "%s/2-bb: " fmt, dev->core->name , ## arg)
static LIST_HEAD(cx8802_devlist);
/* ------------------------------------------------------------------ */
#define BLACKBIRD_FIRM_ENC_FILENAME "blackbird-fw-enc.bin"
#define BLACKBIRD_FIRM_IMAGE_SIZE 256*1024
/* defines below are from ivtv-driver.h */
#define IVTV_CMD_HW_BLOCKS_RST 0xFFFFFFFF
/* Firmware API commands */
/* #define IVTV_API_STD_TIMEOUT 0x00010000 // 65536, units?? */
#define IVTV_API_STD_TIMEOUT 500
#define BLACKBIRD_API_PING 0x80
#define BLACKBIRD_API_BEGIN_CAPTURE 0x81
enum blackbird_capture_type {
BLACKBIRD_MPEG_CAPTURE,
BLACKBIRD_RAW_CAPTURE,
BLACKBIRD_RAW_PASSTHRU_CAPTURE
};
enum blackbird_capture_bits {
BLACKBIRD_RAW_BITS_NONE = 0x00,
BLACKBIRD_RAW_BITS_YUV_CAPTURE = 0x01,
BLACKBIRD_RAW_BITS_PCM_CAPTURE = 0x02,
BLACKBIRD_RAW_BITS_VBI_CAPTURE = 0x04,
BLACKBIRD_RAW_BITS_PASSTHRU_CAPTURE = 0x08,
BLACKBIRD_RAW_BITS_TO_HOST_CAPTURE = 0x10
};
#define BLACKBIRD_API_END_CAPTURE 0x82
enum blackbird_capture_end {
BLACKBIRD_END_AT_GOP, /* stop at the end of gop, generate irq */
BLACKBIRD_END_NOW, /* stop immediately, no irq */
};
#define BLACKBIRD_API_SET_AUDIO_ID 0x89
#define BLACKBIRD_API_SET_VIDEO_ID 0x8B
#define BLACKBIRD_API_SET_PCR_ID 0x8D
#define BLACKBIRD_API_SET_FRAMERATE 0x8F
enum blackbird_framerate {
BLACKBIRD_FRAMERATE_NTSC_30, /* NTSC: 30fps */
BLACKBIRD_FRAMERATE_PAL_25 /* PAL: 25fps */
};
#define BLACKBIRD_API_SET_RESOLUTION 0x91
#define BLACKBIRD_API_SET_VIDEO_BITRATE 0x95
enum blackbird_video_bitrate_type {
BLACKBIRD_VIDEO_VBR,
BLACKBIRD_VIDEO_CBR
};
#define BLACKBIRD_PEAK_RATE_DIVISOR 400
enum blackbird_mux_rate {
BLACKBIRD_MUX_RATE_DEFAULT,
/* dvd mux rate: multiply by 400 to get the actual rate */
BLACKBIRD_MUX_RATE_DVD = 25200
};
#define BLACKBIRD_API_SET_GOP_STRUCTURE 0x97
#define BLACKBIRD_API_SET_ASPECT_RATIO 0x99
enum blackbird_aspect_ratio {
BLACKBIRD_ASPECT_RATIO_FORBIDDEN,
BLACKBIRD_ASPECT_RATIO_1_1_SQUARE,
BLACKBIRD_ASPECT_RATIO_4_3,
BLACKBIRD_ASPECT_RATIO_16_9,
BLACKBIRD_ASPECT_RATIO_221_100,
BLACKBIRD_ASPECT_RATIO_RESERVED
};
#define BLACKBIRD_API_SET_DNR_MODE 0x9B
enum blackbird_dnr_bits {
BLACKBIRD_DNR_BITS_MANUAL,
BLACKBIRD_DNR_BITS_AUTO_SPATIAL,
BLACKBIRD_DNR_BITS_AUTO_TEMPORAL,
BLACKBIRD_DNR_BITS_AUTO
};
enum blackbird_median_filter {
BLACKBIRD_MEDIAN_FILTER_DISABLED,
BLACKBIRD_MEDIAN_FILTER_HORIZONTAL,
BLACKBIRD_MEDIAN_FILTER_VERTICAL,
BLACKBIRD_MEDIAN_FILTER_HV,
BLACKBIRD_MEDIAN_FILTER_DIAGONAL
};
#define BLACKBIRD_API_SET_MANUAL_DNR 0x9D
#define BLACKBIRD_API_SET_DNR_MEDIAN 0x9F
#define BLACKBIRD_API_SET_SPATIAL_FILTER 0xA1
enum blackbird_spatial_filter_luma {
BLACKBIRD_SPATIAL_FILTER_LUMA_DISABLED,
BLACKBIRD_SPATIAL_FILTER_LUMA_1D_HORIZ,
BLACKBIRD_SPATIAL_FILTER_LUMA_1D_VERT,
BLACKBIRD_SPATIAL_FILTER_LUMA_2D_HV, /* separable, default */
BLACKBIRD_SPATIAL_FILTER_LUMA_2D_SYMM /* symmetric non-separable */
};
enum blackbird_spatial_filter_chroma {
BLACKBIRD_SPATIAL_FILTER_CHROMA_DISABLED,
BLACKBIRD_SPATIAL_FILTER_CHROMA_1D_HORIZ /* default */
};
#define BLACKBIRD_API_SET_3_2_PULLDOWN 0xB1
enum blackbird_pulldown {
BLACKBIRD_3_2_PULLDOWN_DISABLED,
BLACKBIRD_3_2_PULLDOWN_ENABLED
};
#define BLACKBIRD_API_SET_VBI_LINE_NO 0xB7
enum blackbird_vbi_line_bits {
BLACKBIRD_VBI_LINE_BITS_TOP_FIELD,
BLACKBIRD_VBI_LINE_BITS_BOT_FIELD = (1