diff options
-rw-r--r-- | linux/drivers/media/video/bttv-driver.c | 8 | ||||
-rw-r--r-- | linux/drivers/media/video/bttv.h | 5 | ||||
-rw-r--r-- | linux/drivers/media/video/saa6752hs.c | 287 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7134/saa6752hs.c | 287 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134-cards.c | 8 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134-empress.c | 9 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134-input.c | 3 | ||||
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134-tvaudio.c | 4 | ||||
-rw-r--r-- | linux/drivers/media/video/tda9887.c | 15 | ||||
-rw-r--r-- | linux/include/linux/videodev2.h | 8 | ||||
-rw-r--r-- | linux/include/media/saa6752hs.h | 29 | ||||
-rw-r--r-- | v4l/Makefile | 4 |
12 files changed, 426 insertions, 241 deletions
diff --git a/linux/drivers/media/video/bttv-driver.c b/linux/drivers/media/video/bttv-driver.c index feb564ed4..b85c14e95 100644 --- a/linux/drivers/media/video/bttv-driver.c +++ b/linux/drivers/media/video/bttv-driver.c @@ -1,5 +1,5 @@ /* - $Id: bttv-driver.c,v 1.28 2004/11/09 11:34:59 kraxel Exp $ + $Id: bttv-driver.c,v 1.29 2004/11/10 11:07:24 kraxel Exp $ bttv - Bt848 frame grabber driver @@ -133,12 +133,6 @@ MODULE_DESCRIPTION("bttv - v4l/v4l2 driver module for bt848/878 based cards"); MODULE_AUTHOR("Ralph Metzler & Marcus Metzler & Gerd Knorr"); MODULE_LICENSE("GPL"); -/* kernel args */ -#ifndef MODULE -static int __init p_radio(char *str) { return bttv_parse(str,BTTV_MAX,radio); } -__setup("bttv.radio=", p_radio); -#endif - /* ----------------------------------------------------------------------- */ /* sysfs */ diff --git a/linux/drivers/media/video/bttv.h b/linux/drivers/media/video/bttv.h index 243e3ca02..6b1778785 100644 --- a/linux/drivers/media/video/bttv.h +++ b/linux/drivers/media/video/bttv.h @@ -1,5 +1,5 @@ /* - * $Id: bttv.h,v 1.10 2004/10/13 10:39:00 kraxel Exp $ + * $Id: bttv.h,v 1.11 2004/11/10 11:07:24 kraxel Exp $ * * bttv - Bt848 frame grabber driver * @@ -230,9 +230,6 @@ extern void bttv_init_card2(struct bttv *btv); extern void tea5757_set_freq(struct bttv *btv, unsigned short freq); extern void bttv_tda9880_setnorm(struct bttv *btv, int norm); -/* kernel cmd line parse helper */ -extern int bttv_parse(char *str, int max, int *vals); - /* extra tweaks for some chipsets */ extern void bttv_check_chipset(void); extern int bttv_handle_chipset(struct bttv *btv); diff --git a/linux/drivers/media/video/saa6752hs.c b/linux/drivers/media/video/saa6752hs.c index 915d418bd..6d3b8b4d1 100644 --- a/linux/drivers/media/video/saa6752hs.c +++ b/linux/drivers/media/video/saa6752hs.c @@ -11,6 +11,7 @@ #include <linux/types.h> #include <linux/videodev.h> #include <linux/init.h> +#include <linux/crc32.h> #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #include "i2c-compat.h" @@ -34,6 +35,10 @@ MODULE_LICENSE("GPL"); static struct i2c_driver driver; static struct i2c_client client_template; +struct saa6752hs_state { + struct i2c_client client; + struct v4l2_mpeg_compression params; +}; enum saa6752hs_command { SAA6752HS_COMMAND_RESET = 0, @@ -47,7 +52,6 @@ enum saa6752hs_command { SAA6752HS_COMMAND_MAX }; - /* ---------------------------------------------------------------------- */ static u8 PAT[] = { @@ -71,9 +75,9 @@ static u8 PAT[] = { 0x00, 0x01, // program_number(1) - 0xe0, 0x10, // PMT PID(0x10) + 0xe0, 0x00, // PMT PID - 0x76, 0xf1, 0x44, 0xd1 // CRC32 + 0x00, 0x00, 0x00, 0x00 // CRC32 }; static u8 PMT[] = { @@ -81,7 +85,7 @@ static u8 PMT[] = { 0x01, // table number for encoder 0x47, // sync - 0x40, 0x10, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid(0x10) + 0x40, 0x00, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid 0x10, // transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0) 0x00, // PSI pointer to start of table @@ -95,28 +99,50 @@ static u8 PMT[] = { 0x00, 0x00, // section_number(0), last_section_number(0) - 0xe1, 0x04, // PCR_PID (0x104) + 0xe0, 0x00, // PCR_PID 0xf0, 0x00, // program_info_length(0) - 0x02, 0xe1, 0x00, 0xf0, 0x00, // video stream type(2), pid(0x100) - 0x04, 0xe1, 0x03, 0xf0, 0x00, // audio stream type(4), pid(0x103) + 0x02, 0xe0, 0x00, 0xf0, 0x00, // video stream type(2), pid + 0x04, 0xe0, 0x00, 0xf0, 0x00, // audio stream type(4), pid - 0xa1, 0xca, 0x0f, 0x82 // CRC32 + 0x00, 0x00, 0x00, 0x00 // CRC32 }; -static struct mpeg_params mpeg_params_template = +static struct v4l2_mpeg_compression param_defaults = { - .bitrate_mode = MPEG_BITRATE_MODE_CBR, - .video_target_bitrate = 5000, - .audio_bitrate = MPEG_AUDIO_BITRATE_256, - .total_bitrate = 6000, + .st_type = V4L2_MPEG_TS_2, + .st_bitrate = { + .mode = V4L2_BITRATE_CBR, + .target = 7000, + }, + + .ts_pid_pmt = 16, + .ts_pid_video = 260, + .ts_pid_audio = 256, + .ts_pid_pcr = 259, + + .vi_type = V4L2_MPEG_VI_2, + .vi_bitrate = { + .mode = V4L2_BITRATE_VBR, + .target = 4000, + .max = 6000, + }, + + .au_type = V4L2_MPEG_AU_2_II, + .au_bitrate = { + .mode = V4L2_BITRATE_CBR, + .target = 256, + }, + +#if 0 + /* FIXME: size? via S_FMT? */ + .video_format = MPEG_VIDEO_FORMAT_D1, +#endif }; - /* ---------------------------------------------------------------------- */ - static int saa6752hs_chip_command(struct i2c_client* client, enum saa6752hs_command command) { @@ -131,7 +157,7 @@ static int saa6752hs_chip_command(struct i2c_client* client, break; case SAA6752HS_COMMAND_STOP: - buf[0] = 0x03; + buf[0] = 0x03; break; case SAA6752HS_COMMAND_START: @@ -187,74 +213,129 @@ static int saa6752hs_chip_command(struct i2c_client* client, static int saa6752hs_set_bitrate(struct i2c_client* client, - struct mpeg_params* params) + struct v4l2_mpeg_compression* params) { u8 buf[3]; // set the bitrate mode buf[0] = 0x71; - buf[1] = params->bitrate_mode; + buf[1] = (params->vi_bitrate.mode == V4L2_BITRATE_VBR) ? 0 : 1; i2c_master_send(client, buf, 2); // set the video bitrate - if (params->bitrate_mode == MPEG_BITRATE_MODE_VBR) { + if (params->vi_bitrate.mode == V4L2_BITRATE_VBR) { // set the target bitrate buf[0] = 0x80; - buf[1] = params->video_target_bitrate >> 8; - buf[2] = params->video_target_bitrate & 0xff; + buf[1] = params->vi_bitrate.target >> 8; + buf[2] = params->vi_bitrate.target & 0xff; i2c_master_send(client, buf, 3); // set the max bitrate buf[0] = 0x81; - buf[1] = params->video_max_bitrate >> 8; - buf[2] = params->video_max_bitrate & 0xff; + buf[1] = params->vi_bitrate.max >> 8; + buf[2] = params->vi_bitrate.max & 0xff; i2c_master_send(client, buf, 3); } else { // set the target bitrate (no max bitrate for CBR) buf[0] = 0x81; - buf[1] = params->video_target_bitrate >> 8; - buf[2] = params->video_target_bitrate & 0xff; + buf[1] = params->vi_bitrate.target >> 8; + buf[2] = params->vi_bitrate.target & 0xff; i2c_master_send(client, buf, 3); } // set the audio bitrate buf[0] = 0x94; - buf[1] = params->audio_bitrate; + buf[1] = params->au_bitrate.target; i2c_master_send(client, buf, 2); // set the total bitrate buf[0] = 0xb1; - buf[1] = params->total_bitrate >> 8; - buf[2] = params->total_bitrate & 0xff; + buf[1] = params->st_bitrate.target >> 8; + buf[2] = params->st_bitrate.target & 0xff; i2c_master_send(client, buf, 3); + // return success return 0; } -static int saa6752hs_init(struct i2c_client* client, struct mpeg_params* params) +static int saa6752hs_init(struct i2c_client* client, + struct v4l2_mpeg_compression* params) { unsigned char buf[3]; - void *data; + struct saa6752hs_state *h; + u32 crc; + unsigned char localPAT[256]; + unsigned char localPMT[256]; + + // grab the previous set of parameters + h = i2c_get_clientdata(client); + +#if 0 /* TODO: verify parameters and update h->params */ // check the bitrate parameters first if (params != NULL) { - if (params->bitrate_mode >= MPEG_BITRATE_MODE_MAX) + unsigned int pmt_pid = 0, pcr_pid = 0, video_pid = 0 , audio_pid = 0; + + // check supplied params are valid + if (params->video_format >= MPEG_VIDEO_FORMAT_MAX) return -EINVAL; - if (params->video_target_bitrate >= MPEG_VIDEO_TARGET_BITRATE_MAX) + if (params->video_bitrate_mode >= MPEG_VIDEO_BITRATE_MODE_MAX) return -EINVAL; - if (params->video_max_bitrate >= MPEG_VIDEO_MAX_BITRATE_MAX) + if (params->video_target_bitrate >= MPEG_VIDEO_TARGET_BITRATE_MAX) return -EINVAL; if (params->audio_bitrate >= MPEG_AUDIO_BITRATE_MAX) return -EINVAL; if (params->total_bitrate >= MPEG_TOTAL_BITRATE_MAX) return -EINVAL; - if (params->bitrate_mode == MPEG_BITRATE_MODE_MAX && - params->video_target_bitrate <= params->video_max_bitrate) - return -EINVAL; + if (params->video_bitrate_mode == MPEG_VIDEO_BITRATE_MODE_VBR) { + if (params->video_max_bitrate >= MPEG_VIDEO_MAX_BITRATE_MAX) + return -EINVAL; + if (params->video_target_bitrate >= params->video_max_bitrate) + return -EINVAL; + } + if (params->pmt_pid != 0) { + if (params->pmt_pid > MPEG_PID_MAX) + return -EINVAL; + pmt_pid = params->pmt_pid; + } else { + pmt_pid = cachedParams->pmt_pid; + } + if (params->pcr_pid != 0) { + if (params->pcr_pid > MPEG_PID_MAX) + return -EINVAL; + pcr_pid = params->pcr_pid; + } else { + pcr_pid = cachedParams->pcr_pid; + } + if (params->video_pid != 0) { + if (params->video_pid > MPEG_PID_MAX) + return -EINVAL; + video_pid = params->video_pid; + } else { + video_pid = cachedParams->video_pid; + } + if (params->audio_pid != 0) { + if (params->audio_pid > MPEG_PID_MAX) + return -EINVAL; + audio_pid = params->audio_pid; + } else { + audio_pid = cachedParams->audio_pid; + } + + // update cache + memcpy(cachedParams, params, sizeof(struct mpeg_params)); + cachedParams->pmt_pid = pmt_pid; + cachedParams->pcr_pid = pcr_pid; + cachedParams->video_pid = video_pid; + cachedParams->audio_pid = audio_pid; } +#endif + + // set bitrate + saa6752hs_set_bitrate(client, &h->params); - // Set GOP structure {3, 13} + // Set GOP structure {3, 13} buf[0] = 0x72; buf[1] = 0x03; buf[2] = 0x0D; @@ -280,25 +361,53 @@ static int saa6752hs_init(struct i2c_client* client, struct mpeg_params* params) buf[1] = 0x05; i2c_master_send(client,buf,2); - // Set Audio PID {0x103} + /* compute PAT */ + memcpy(localPAT, PAT, sizeof(PAT)); + localPAT[17] = 0xe0 | ((h->params.ts_pid_pmt >> 8) & 0x0f); + localPAT[18] = h->params.ts_pid_pmt & 0xff; + crc = crc32_be(~0, &localPAT[7], sizeof(PAT) - 7 - 4); + localPAT[sizeof(PAT) - 4] = (crc >> 24) & 0xFF; + localPAT[sizeof(PAT) - 3] = (crc >> 16) & 0xFF; + localPAT[sizeof(PAT) - 2] = (crc >> 8) & 0xFF; + localPAT[sizeof(PAT) - 1] = crc & 0xFF; + + /* compute PMT */ + memcpy(localPMT, PMT, sizeof(PMT)); + localPMT[3] = 0x40 | ((h->params.ts_pid_pmt >> 8) & 0x0f); + localPMT[4] = h->params.ts_pid_pmt & 0xff; + localPMT[15] = 0xE0 | ((h->params.ts_pid_pcr >> 8) & 0x0F); + localPMT[16] = h->params.ts_pid_pcr & 0xFF; + localPMT[20] = 0xE0 | ((h->params.ts_pid_video >> 8) & 0x0F); + localPMT[21] = h->params.ts_pid_video & 0xFF; + localPMT[25] = 0xE0 | ((h->params.ts_pid_audio >> 8) & 0x0F); + localPMT[26] = h->params.ts_pid_audio & 0xFF; + crc = crc32_be(~0, &localPMT[7], sizeof(PMT) - 7 - 4); + localPMT[sizeof(PMT) - 4] = (crc >> 24) & 0xFF; + localPMT[sizeof(PMT) - 3] = (crc >> 16) & 0xFF; + localPMT[sizeof(PMT) - 2] = (crc >> 8) & 0xFF; + localPMT[sizeof(PMT) - 1] = crc & 0xFF; + + // Set Audio PID buf[0] = 0xC1; - buf[1] = 0x01; - buf[2] = 0x03; + buf[1] = (h->params.ts_pid_audio >> 8) & 0xFF; + buf[2] = h->params.ts_pid_audio & 0xFF; i2c_master_send(client,buf,3); - // setup bitrate settings - data = i2c_get_clientdata(client); - if (params) { - saa6752hs_set_bitrate(client, params); - memcpy(data, params, sizeof(struct mpeg_params)); - } else { - // parameters were not supplied. use the previous set - saa6752hs_set_bitrate(client, (struct mpeg_params*) data); - } + // Set Video PID + buf[0] = 0xC0; + buf[1] = (h->params.ts_pid_video >> 8) & 0xFF; + buf[2] = h->params.ts_pid_video & 0xFF; + i2c_master_send(client,buf,3); + + // Set PCR PID + buf[0] = 0xC4; + buf[1] = (h->params.ts_pid_pcr >> 8) & 0xFF; + buf[2] = h->params.ts_pid_pcr & 0xFF; + i2c_master_send(client,buf,3); // Send SI tables - i2c_master_send(client,PAT,sizeof(PAT)); - i2c_master_send(client,PMT,sizeof(PMT)); + i2c_master_send(client,localPAT,sizeof(PAT)); + i2c_master_send(client,localPMT,sizeof(PMT)); // mute then unmute audio. This removes buzzing artefacts buf[0] = 0xa4; @@ -307,97 +416,83 @@ static int saa6752hs_init(struct i2c_client* client, struct mpeg_params* params) buf[1] = 0; i2c_master_send(client, buf, 2); + // Set video format + buf[0] = 0x41; + buf[1] = 0 /* MPEG_VIDEO_FORMAT_D1 */; + i2c_master_send(client, buf, 2); + // start it going saa6752hs_chip_command(client, SAA6752HS_COMMAND_START); + // return success return 0; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind) -#else -static int saa6752hs_attach(struct i2c_adapter *adap, int addr, - unsigned short flags, int kind) -#endif { - struct i2c_client *client; - struct mpeg_params* params; - - client_template.adapter = adap; - client_template.addr = addr; + struct saa6752hs_state *h; printk("saa6752hs: chip found @ 0x%x\n", addr<<1); - if (NULL == (client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) + if (NULL == (h = kmalloc(sizeof(*h), GFP_KERNEL))) return -ENOMEM; - memcpy(client,&client_template,sizeof(struct i2c_client)); - strlcpy(client->name, "saa6752hs", sizeof(client->name)); - - if (NULL == (params = kmalloc(sizeof(struct mpeg_params), GFP_KERNEL))) - return -ENOMEM; - memcpy(params,&mpeg_params_template,sizeof(struct mpeg_params)); - i2c_set_clientdata(client, params); + memset(h,0,sizeof(*h)); + h->client = client_template; + h->params = param_defaults; + h->client.adapter = adap; + h->client.addr = addr; - i2c_attach_client(client); + i2c_set_clientdata(&h->client, h); + i2c_attach_client(&h->client); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - MOD_INC_USE_COUNT; -#endif + saa6752hs_init(&h->client, NULL); return 0; } static int saa6752hs_probe(struct i2c_adapter *adap) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) if (adap->class & I2C_CLASS_TV_ANALOG) return i2c_probe(adap, &addr_data, saa6752hs_attach); -#else - switch (adap->id) { - case I2C_ALGO_SAA7134: - return i2c_probe(adap, &addr_data, saa6752hs_attach); - break; - } -#endif return 0; } static int saa6752hs_detach(struct i2c_client *client) { - void *data; + struct saa6752hs_state *h; - data = i2c_get_clientdata(client); + h = i2c_get_clientdata(client); i2c_detach_client(client); - kfree(data); - kfree(client); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - MOD_DEC_USE_COUNT; -#endif + kfree(h); return 0; } static int saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg) { - struct mpeg_params* init_arg = arg; + struct saa6752hs_state *h = i2c_get_clientdata(client); + struct v4l2_mpeg_compression *params = arg; + int err = 0; switch (cmd) { - case MPEG_SETPARAMS: - return saa6752hs_init(client, init_arg); - + case VIDIOC_S_MPEGCOMP: + err = saa6752hs_init(client, params); + /* fall through */ + case VIDIOC_G_MPEGCOMP: + if (params) + *params = h->params; + break; default: /* nothing */ break; } - return 0; + return err; } /* ----------------------------------------------------------------------- */ static struct i2c_driver driver = { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,54) .owner = THIS_MODULE, -#endif .name = "i2c saa6752hs MPEG encoder", .id = I2C_DRIVERID_SAA6752HS, .flags = I2C_DF_NOTIFY, @@ -408,7 +503,7 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { - I2C_DEVNAME("(saa6752hs unset)"), + I2C_DEVNAME("saa6752hs"), .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/linux/drivers/media/video/saa7134/saa6752hs.c b/linux/drivers/media/video/saa7134/saa6752hs.c index 915d418bd..6d3b8b4d1 100644 --- a/linux/drivers/media/video/saa7134/saa6752hs.c +++ b/linux/drivers/media/video/saa7134/saa6752hs.c @@ -11,6 +11,7 @@ #include <linux/types.h> #include <linux/videodev.h> #include <linux/init.h> +#include <linux/crc32.h> #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #include "i2c-compat.h" @@ -34,6 +35,10 @@ MODULE_LICENSE("GPL"); static struct i2c_driver driver; static struct i2c_client client_template; +struct saa6752hs_state { + struct i2c_client client; + struct v4l2_mpeg_compression params; +}; enum saa6752hs_command { SAA6752HS_COMMAND_RESET = 0, @@ -47,7 +52,6 @@ enum saa6752hs_command { SAA6752HS_COMMAND_MAX }; - /* ---------------------------------------------------------------------- */ static u8 PAT[] = { @@ -71,9 +75,9 @@ static u8 PAT[] = { 0x00, 0x01, // program_number(1) - 0xe0, 0x10, // PMT PID(0x10) + 0xe0, 0x00, // PMT PID - 0x76, 0xf1, 0x44, 0xd1 // CRC32 + 0x00, 0x00, 0x00, 0x00 // CRC32 }; static u8 PMT[] = { @@ -81,7 +85,7 @@ static u8 PMT[] = { 0x01, // table number for encoder 0x47, // sync - 0x40, 0x10, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid(0x10) + 0x40, 0x00, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid 0x10, // transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0) 0x00, // PSI pointer to start of table @@ -95,28 +99,50 @@ static u8 PMT[] = { 0x00, 0x00, // section_number(0), last_section_number(0) - 0xe1, 0x04, // PCR_PID (0x104) + 0xe0, 0x00, // PCR_PID 0xf0, 0x00, // program_info_length(0) - 0x02, 0xe1, 0x00, 0xf0, 0x00, // video stream type(2), pid(0x100) - 0x04, 0xe1, 0x03, 0xf0, 0x00, // audio stream type(4), pid(0x103) + 0x02, 0xe0, 0x00, 0xf0, 0x00, // video stream type(2), pid + 0x04, 0xe0, 0x00, 0xf0, 0x00, // audio stream type(4), pid - 0xa1, 0xca, 0x0f, 0x82 // CRC32 + 0x00, 0x00, 0x00, 0x00 // CRC32 }; -static struct mpeg_params mpeg_params_template = +static struct v4l2_mpeg_compression param_defaults = { - .bitrate_mode = MPEG_BITRATE_MODE_CBR, - .video_target_bitrate = 5000, - .audio_bitrate = MPEG_AUDIO_BITRATE_256, - .total_bitrate = 6000, + .st_type = V4L2_MPEG_TS_2, + .st_bitrate = { + .mode = V4L2_BITRATE_CBR, + .target = 7000, + }, + + .ts_pid_pmt = 16, + .ts_pid_video = 260, + .ts_pid_audio = 256, + .ts_pid_pcr = 259, + + .vi_type = V4L2_MPEG_VI_2, + .vi_bitrate = { + .mode = V4L2_BITRATE_VBR, + .target = 4000, + .max = 6000, + }, + + .au_type = V4L2_MPEG_AU_2_II, + .au_bitrate = { + .mode = V4L2_BITRATE_CBR, + .target = 256, + }, + +#if 0 + /* FIXME: size? via S_FMT? */ + .video_format = MPEG_VIDEO_FORMAT_D1, +#endif }; - /* ---------------------------------------------------------------------- */ - static int saa6752hs_chip_command(struct i2c_client* client, enum saa6752hs_command command) { @@ -131,7 +157,7 @@ static int saa6752hs_chip_command(struct i2c_client* client, break; case SAA6752HS_COMMAND_STOP: - buf[0] = 0x03; + buf[0] = 0x03; break; case SAA6752HS_COMMAND_START: @@ -187,74 +213,129 @@ static int saa6752hs_chip_command(struct i2c_client* client, static int saa6752hs_set_bitrate(struct i2c_client* client, - struct mpeg_params* params) + struct v4l2_mpeg_compression* params) { u8 buf[3]; // set the bitrate mode buf[0] = 0x71; - buf[1] = params->bitrate_mode; + buf[1] = (params->vi_bitrate.mode == V4L2_BITRATE_VBR) ? 0 : 1; i2c_master_send(client, buf, 2); // set the video bitrate - if (params->bitrate_mode == MPEG_BITRATE_MODE_VBR) { + if (params->vi_bitrate.mode == V4L2_BITRATE_VBR) { // set the target bitrate buf[0] = 0x80; - buf[1] = params->video_target_bitrate >> 8; - buf[2] = params->video_target_bitrate & 0xff; + buf[1] = params->vi_bitrate.target >> 8; + buf[2] = params->vi_bitrate.target & 0xff; i2c_master_send(client, buf, 3); // set the max bitrate buf[0] = 0x81; - buf[1] = params->video_max_bitrate >> 8; - buf[2] = params->video_max_bitrate & 0xff; + buf[1] = params->vi_bitrate.max >> 8; + buf[2] = params->vi_bitrate.max & 0xff; i2c_master_send(client, buf, 3); } else { // set the target bitrate (no max bitrate for CBR) buf[0] = 0x81; - buf[1] = params->video_target_bitrate >> 8; - buf[2] = params->video_target_bitrate & 0xff; + buf[1] = params->vi_bitrate.target >> 8; + buf[2] = params->vi_bitrate.target & 0xff; i2c_master_send(client, buf, 3); } // set the audio bitrate buf[0] = 0x94; - buf[1] = params->audio_bitrate; + buf[1] = params->au_bitrate.target; i2c_master_send(client, buf, 2); // set the total bitrate buf[0] = 0xb1; - buf[1] = params->total_bitrate >> 8; - buf[2] = params->total_bitrate & 0xff; + buf[1] = params->st_bitrate.target >> 8; + buf[2] = params->st_bitrate.target & 0xff; i2c_master_send(client, buf, 3); + // return success return 0; } -static int saa6752hs_init(struct i2c_client* client, struct mpeg_params* params) +static int saa6752hs_init(struct i2c_client* client, + struct v4l2_mpeg_compression* params) { unsigned char buf[3]; - void *data; + struct saa6752hs_state *h; + u32 crc; + unsigned char localPAT[256]; + unsigned char localPMT[256]; + + // grab the previous set of parameters + h = i2c_get_clientdata(client); + +#if 0 /* TODO: verify parameters and update h->params */ // check the bitrate parameters first if (params != NULL) { - if (params->bitrate_mode >= MPEG_BITRATE_MODE_MAX) + unsigned int pmt_pid = 0, pcr_pid = 0, video_pid = 0 , audio_pid = 0; + + // check supplied params are valid + if (params->video_format >= MPEG_VIDEO_FORMAT_MAX) return -EINVAL; - if (params->video_target_bitrate >= MPEG_VIDEO_TARGET_BITRATE_MAX) + if (params->video_bitrate_mode >= MPEG_VIDEO_BITRATE_MODE_MAX) return -EINVAL; - if (params->video_max_bitrate >= MPEG_VIDEO_MAX_BITRATE_MAX) + if (params->video_target_bitrate >= MPEG_VIDEO_TARGET_BITRATE_MAX) return -EINVAL; if (params->audio_bitrate >= MPEG_AUDIO_BITRATE_MAX) return -EINVAL; if (params->total_bitrate >= MPEG_TOTAL_BITRATE_MAX) return -EINVAL; - if (params->bitrate_mode == MPEG_BITRATE_MODE_MAX && - params->video_target_bitrate <= params->video_max_bitrate) - return -EINVAL; + if (params->video_bitrate_mode == MPEG_VIDEO_BITRATE_MODE_VBR) { + if (params->video_max_bitrate >= MPEG_VIDEO_MAX_BITRATE_MAX) + return -EINVAL; + if (params->video_target_bitrate >= params->video_max_bitrate) + return -EINVAL; + } + if (params->pmt_pid != 0) { + if (params->pmt_pid > MPEG_PID_MAX) + return -EINVAL; + pmt_pid = params->pmt_pid; + } else { + pmt_pid = cachedParams->pmt_pid; + } + if (params->pcr_pid != 0) { + if (params->pcr_pid > MPEG_PID_MAX) + return -EINVAL; + pcr_pid = params->pcr_pid; + } else { + pcr_pid = cachedParams->pcr_pid; + } + if (params->video_pid != 0) { + if (params->video_pid > MPEG_PID_MAX) + return -EINVAL; + video_pid = params->video_pid; + } else { + video_pid = cachedParams->video_pid; + } + if (params->audio_pid != 0) { + if (params->audio_pid > MPEG_PID_MAX) + return -EINVAL; + audio_pid = params->audio_pid; + } else { + audio_pid = cachedParams->audio_pid; + } + + // update cache + memcpy(cachedParams, params, sizeof(struct mpeg_params)); + cachedParams->pmt_pid = pmt_pid; + cachedParams->pcr_pid = pcr_pid; + cachedParams->video_pid = video_pid; + cachedParams->audio_pid = audio_pid; } +#endif + + // set bitrate + saa6752hs_set_bitrate(client, &h->params); - // Set GOP structure {3, 13} + // Set GOP structure {3, 13} buf[0] = 0x72; buf[1] = 0x03; buf[2] = 0x0D; @@ -280,25 +361,53 @@ static int saa6752hs_init(struct i2c_client* client, struct mpeg_params* params) buf[1] = 0x05; i2c_master_send(client,buf,2); - // Set Audio PID {0x103} + /* compute PAT */ + memcpy(localPAT, PAT, sizeof(PAT)); + localPAT[17] = 0xe0 | ((h->params.ts_pid_pmt >> 8) & 0x0f); + localPAT[18] = h->params.ts_pid_pmt & 0xff; + crc = crc32_be(~0, &localPAT[7], sizeof(PAT) - 7 - 4); + localPAT[sizeof(PAT) - 4] = (crc >> 24) & 0xFF; + localPAT[sizeof(PAT) - 3] = (crc >> 16) & 0xFF; + localPAT[sizeof(PAT) - 2] = (crc >> 8) & 0xFF; + localPAT[sizeof(PAT) - 1] = crc & 0xFF; + + /* compute PMT */ + memcpy(localPMT, PMT, sizeof(PMT)); + localPMT[3] = 0x40 | ((h->params.ts_pid_pmt >> 8) & 0x0f); + localPMT[4] = h->params.ts_pid_pmt & 0xff; + localPMT[15] = 0xE0 | ((h->params.ts_pid_pcr >> 8) & 0x0F); + localPMT[16] = h->params.ts_pid_pcr & 0xFF; + localPMT[20] = 0xE0 | ((h->params.ts_pid_video >> 8) & 0x0F); + localPMT[21] = h->params.ts_pid_video & 0xFF; + localPMT[25] = 0xE0 | ((h->params.ts_pid_audio >> 8) & 0x0F); + localPMT[26] = h->params.ts_pid_audio & 0xFF; + crc = crc32_be(~0, &localPMT[7], sizeof(PMT) - 7 - 4); + localPMT[sizeof(PMT) - 4] = (crc >> 24) & 0xFF; + localPMT[sizeof(PMT) - 3] = (crc >> 16) & 0xFF; + localPMT[sizeof(PMT) - 2] = (crc >> 8) & 0xFF; + localPMT[sizeof(PMT) - 1] = crc & 0xFF; + + // Set Audio PID buf[0] = 0xC1; - buf[1] = 0x01; - buf[2] = 0x03; + buf[1] = (h->params.ts_pid_audio >> 8) & 0xFF; + buf[2] = h->params.ts_pid_audio & 0xFF; i2c_master_send(client,buf,3); - // setup bitrate settings - data = i2c_get_clientdata(client); - if (params) { - saa6752hs_set_bitrate(client, params); - memcpy(data, params, sizeof(struct mpeg_params)); - } else { - // parameters were not supplied. use the previous set - saa6752hs_set_bitrate(client, (struct mpeg_params*) data); - } + // Set Video PID + buf[0] = 0xC0; + buf[1] = (h->params.ts_pid_video >> 8) & 0xFF; + buf[2] = h->params.ts_pid_video & 0xFF; + i2c_master_send(client,buf,3); + + // Set PCR PID + buf[0] = 0xC4; + buf[1] = (h->params.ts_pid_pcr >> 8) & 0xFF; + buf[2] = h->params.ts_pid_pcr & 0xFF; + i2c_master_send(client,buf,3); // Send SI tables - i2c_master_send(client,PAT,sizeof(PAT)); - i2c_master_send(client,PMT,sizeof(PMT)); + i2c_master_send(client,localPAT,sizeof(PAT)); + i2c_master_send(client,localPMT,sizeof(PMT)); // mute then unmute audio. This removes buzzing artefacts buf[0] = 0xa4; @@ -307,97 +416,83 @@ static int saa6752hs_init(struct i2c_client* client, struct mpeg_params* params) buf[1] = 0; i2c_master_send(client, buf, 2); + // Set video format + buf[0] = 0x41; + buf[1] = 0 /* MPEG_VIDEO_FORMAT_D1 */; + i2c_master_send(client, buf, 2); + // start it going saa6752hs_chip_command(client, SAA6752HS_COMMAND_START); + // return success return 0; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind) -#else -static int saa6752hs_attach(struct i2c_adapter *adap, int addr, - unsigned short flags, int kind) -#endif { - struct i2c_client *client; - struct mpeg_params* params; - - client_template.adapter = adap; - client_template.addr = addr; + struct saa6752hs_state *h; printk("saa6752hs: chip found @ 0x%x\n", addr<<1); - if (NULL == (client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) + if (NULL == (h = kmalloc(sizeof(*h), GFP_KERNEL))) return -ENOMEM; - memcpy(client,&client_template,sizeof(struct i2c_client)); - strlcpy(client->name, "saa6752hs", sizeof(client->name)); - - if (NULL == (params = kmalloc(sizeof(struct mpeg_params), GFP_KERNEL))) - return -ENOMEM; - memcpy(params,&mpeg_params_template,sizeof(struct mpeg_params)); - i2c_set_clientdata(client, params); + memset(h,0,sizeof(*h)); + h->client = client_template; + h->params = param_defaults; + h->client.adapter = adap; + h->client.addr = addr; - i2c_attach_client(client); + i2c_set_clientdata(&h->client, h); + i2c_attach_client(&h->client); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - MOD_INC_USE_COUNT; -#endif + saa6752hs_init(&h->client, NULL); return 0; } static int saa6752hs_probe(struct i2c_adapter *adap) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) if (adap->class & I2C_CLASS_TV_ANALOG) return i2c_probe(adap, &addr_data, saa6752hs_attach); -#else - switch (adap->id) { - case I2C_ALGO_SAA7134: - return i2c_probe(adap, &addr_data, saa6752hs_attach); - break; - } -#endif return 0; } static int saa6752hs_detach(struct i2c_client *client) { - void *data; + struct saa6752hs_state *h; - data = i2c_get_clientdata(client); + h = i2c_get_clientdata(client); i2c_detach_client(client); - kfree(data); - kfree(client); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - MOD_DEC_USE_COUNT; -#endif + kfree(h); return 0; } static int saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg) { - struct mpeg_params* init_arg = arg; + struct saa6752hs_state *h = i2c_get_clientdata(client); + struct v4l2_mpeg_compression *params = arg; + int err = 0; switch (cmd) { - case MPEG_SETPARAMS: - return saa6752hs_init(client, init_arg); - + case VIDIOC_S_MPEGCOMP: + err = saa6752hs_init(client, params); + /* fall through */ + case VIDIOC_G_MPEGCOMP: + if (params) + *params = h->params; + break; default: /* nothing */ break; } - return 0; + return err; } /* ----------------------------------------------------------------------- */ static struct i2c_driver driver = { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,54) .owner = THIS_MODULE, -#endif .name = "i2c saa6752hs MPEG encoder", .id = I2C_DRIVERID_SAA6752HS, .flags = I2C_DF_NOTIFY, @@ -408,7 +503,7 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { - I2C_DEVNAME("(saa6752hs unset)"), + I2C_DEVNAME("saa6752hs"), .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/linux/drivers/media/video/saa7134/saa7134-cards.c b/linux/drivers/media/video/saa7134/saa7134-cards.c index a7ad005c3..3a7bc2735 100644 --- a/linux/drivers/media/video/saa7134/saa7134-cards.c +++ b/linux/drivers/media/video/saa7134/saa7134-cards.c @@ -1,5 +1,5 @@ /* - * $Id: saa7134-cards.c,v 1.37 2004/11/09 11:34:59 kraxel Exp $ + * $Id: saa7134-cards.c,v 1.38 2004/11/10 11:07:24 kraxel Exp $ * * device driver for philips saa7134 based TV cards * card-specific stuff. @@ -1006,27 +1006,22 @@ struct saa7134_board saa7134_boards[] = { .vmux = 1, .amux = LINE2, .tv = 1, - .gpio = 0x0, },{ .name = name_comp1, .vmux = 0, .amux = LINE2, - .gpio = 0x0, },{ .name = name_comp2, .vmux = 3, .amux = LINE2, - .gpio = 0x0, },{ .name = name_svideo, .vmux = 8, .amux = LINE2, - .gpio = 0x0, }}, .radio = { .name = name_radio, .amux = LINE2, - .gpio = 0x1, }, .mute = { .name = name_mute, @@ -1698,6 +1693,7 @@ int saa7134_board_init2(struct saa7134_dev *dev) : SAA7134_BOARD_BMK_MPEX_TUNER; if (board == dev->board) break; + dev->board = board; printk("%s: board type fixup: %s\n", dev->name, saa7134_boards[dev->board].name); dev->tuner_type = saa7134_boards[dev->board].tuner_type; diff --git a/linux/drivers/media/video/saa7134/saa7134-empress.c b/linux/drivers/media/video/saa7134/saa7134-empress.c index 4decb992b..dba969402 100644 --- a/linux/drivers/media/video/saa7134/saa7134-empress.c +++ b/linux/drivers/media/video/saa7134/saa7134-empress.c @@ -1,5 +1,5 @@ /* - * $Id: saa7134-empress.c,v 1.4 2004/11/09 11:34:59 kraxel Exp $ + * $Id: saa7134-empress.c,v 1.5 2004/11/10 11:07:24 kraxel Exp $ * * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] * @@ -68,7 +68,7 @@ static void ts_reset_encoder(struct saa7134_dev* dev) static int ts_init_encoder(struct saa7134_dev* dev, void* arg) { ts_reset_encoder(dev); - saa7134_i2c_call_clients(dev, MPEG_SETPARAMS, arg); + saa7134_i2c_call_clients(dev, VIDIOC_S_MPEGCOMP, arg); return 0; } @@ -290,8 +290,11 @@ static int ts_do_ioctl(struct inode *inode, struct file *file, case VIDIOC_S_CTRL: return saa7134_common_ioctl(dev, cmd, arg); - case MPEG_SETPARAMS: + case VIDIOC_S_MPEGCOMP: return ts_init_encoder(dev, arg); + case VIDIOC_G_MPEGCOMP: + saa7134_i2c_call_clients(dev, VIDIOC_G_MPEGCOMP, arg); + return 0; default: return -ENOIOCTLCMD; diff --git a/linux/drivers/media/video/saa7134/saa7134-input.c b/linux/drivers/media/video/saa7134/saa7134-input.c index 07431c822..b925aad68 100644 --- a/linux/drivers/media/video/saa7134/saa7134-input.c +++ b/linux/drivers/media/video/saa7134/saa7134-input.c @@ -1,5 +1,5 @@ /* - * $Id: saa7134-input.c,v 1.12 2004/11/07 13:17:15 kraxel Exp $ + * $Id: saa7134-input.c,v 1.13 2004/11/10 11:07:24 kraxel Exp $ * * handle saa7134 IR remotes via linux kernel input layer. * @@ -353,6 +353,7 @@ int saa7134_input_init1(struct saa7134_dev *dev) polling = 50; // ms break; case SAA7134_BOARD_MD2819: + case SAA7134_BOARD_AVERMEDIA_305: case SAA7134_BOARD_AVERMEDIA_307: ir_codes = md2819_codes; mask_keycode = 0x0007C8; diff --git a/linux/drivers/media/video/saa7134/saa7134-tvaudio.c b/linux/drivers/media/video/saa7134/saa7134-tvaudio.c index 799e7bd90..251aa73d4 100644 --- a/linux/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/linux/drivers/media/video/saa7134/saa7134-tvaudio.c @@ -1,5 +1,5 @@ /* - * $Id: saa7134-tvaudio.c,v 1.17 2004/11/07 13:17:15 kraxel Exp $ + * $Id: saa7134-tvaudio.c,v 1.18 2004/11/10 11:07:24 kraxel Exp $ * * device driver for philips saa7134 based TV cards * tv audio decoder (fm stereo, nicam, ...) @@ -993,7 +993,7 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) if (dev->thread.pid < 0) printk(KERN_WARNING "%s: kernel_thread() failed\n", dev->name); - wake_up_interruptible(&dev->thread.wq); + saa7134_tvaudio_do_scan(dev); } return 0; diff --git a/linux/drivers/media/video/tda9887.c b/linux/drivers/media/video/tda9887.c index 90d210c2c..b9c11ca25 100644 --- a/linux/drivers/media/video/tda9887.c +++ b/linux/drivers/media/video/tda9887.c @@ -18,6 +18,7 @@ #include <media/tuner.h> #include <media/id.h> #endif +#include "compat.h" /* Chips: TDA9885 (PAL, NTSC) @@ -228,20 +229,6 @@ static struct tvnorm radio = { cRadioIF_38_90 ), }; -#if 0 /* do we really need this ? */ -static struct tvnorm ih3_radio = { - .name = "radio", - .b = ( cFmRadio | - cQSS | - cAutoMuteFmActive), - .c = 0x10, /* ??? */ - .e = (cAudioIF_6_5 | - cVideoIF_38_90 | - cGating_36 | - cTunerGainLow), -}; -#endif - /* ---------------------------------------------------------------------- */ static void dump_read_message(unsigned char *buf) diff --git a/linux/include/linux/videodev2.h b/linux/include/linux/videodev2.h index 15571c046..f75722fd3 100644 --- a/linux/include/linux/videodev2.h +++ b/linux/include/linux/videodev2.h @@ -276,7 +276,7 @@ struct v4l2_timecode enum v4l2_bitrate_mode { - V4L2_BITRATE_NONE, /* not specified */ + V4L2_BITRATE_NONE = 0, /* not specified */ V4L2_BITRATE_CBR, /* constant bitrate */ V4L2_BITRATE_VBR, /* variable bitrate */ }; @@ -858,9 +858,9 @@ struct v4l2_streamparm #define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) #define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) #define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) -#if 0 -#define VIDIOC_G_COMP _IOR ('V', 6, struct v4l2_compression) -#define VIDIOC_S_COMP _IOW ('V', 7, struct v4l2_compression) +#if 1 /* experimental */ +#define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression) +#define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression) #endif #define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) #define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) diff --git a/linux/include/media/saa6752hs.h b/linux/include/media/saa6752hs.h index 135f9a682..791bad2b8 100644 --- a/linux/include/media/saa6752hs.h +++ b/linux/include/media/saa6752hs.h @@ -18,14 +18,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef _SAA6752HS_H +#if 0 /* ndef _SAA6752HS_H */ #define _SAA6752HS_H -enum mpeg_bitrate_mode { - MPEG_BITRATE_MODE_VBR = 0, /* Variable bitrate */ - MPEG_BITRATE_MODE_CBR = 1, /* Constant bitrate */ +enum mpeg_video_bitrate_mode { + MPEG_VIDEO_BITRATE_MODE_VBR = 0, /* Variable bitrate */ + MPEG_VIDEO_BITRATE_MODE_CBR = 1, /* Constant bitrate */ - MPEG_BITRATE_MODE_MAX + MPEG_VIDEO_BITRATE_MODE_MAX }; enum mpeg_audio_bitrate { @@ -35,16 +35,33 @@ enum mpeg_audio_bitrate { MPEG_AUDIO_BITRATE_MAX }; +enum mpeg_video_format { + MPEG_VIDEO_FORMAT_D1 = 0, + MPEG_VIDEO_FORMAT_2_3_D1 = 1, + MPEG_VIDEO_FORMAT_1_2_D1 = 2, + MPEG_VIDEO_FORMAT_SIF = 3, + + MPEG_VIDEO_FORMAT_MAX +}; + #define MPEG_VIDEO_TARGET_BITRATE_MAX 27000 #define MPEG_VIDEO_MAX_BITRATE_MAX 27000 #define MPEG_TOTAL_BITRATE_MAX 27000 +#define MPEG_PID_MAX ((1 << 14) - 1) struct mpeg_params { - enum mpeg_bitrate_mode bitrate_mode; + enum mpeg_video_bitrate_mode video_bitrate_mode; unsigned int video_target_bitrate; unsigned int video_max_bitrate; // only used for VBR enum mpeg_audio_bitrate audio_bitrate; unsigned int total_bitrate; + + unsigned int pmt_pid; + unsigned int video_pid; + unsigned int audio_pid; + unsigned int pcr_pid; + + enum mpeg_video_format video_format; }; #define MPEG_SETPARAMS _IOW('6',100,struct mpeg_params) diff --git a/v4l/Makefile b/v4l/Makefile index 970b1a5f5..e726cad6d 100644 --- a/v4l/Makefile +++ b/v4l/Makefile @@ -52,8 +52,8 @@ ifeq ($(VERSION).$(PATCHLEVEL),2.6) endif # for DVB -EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -EXTRA_CFLAGS += -Idrivers/media/dvb/frontends/ +EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core/ +EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends/ ifeq ($(CONFIG_VIDEO_CX88_DVB),m) EXTRA_CFLAGS += -DCONFIG_VIDEO_CX88_DVB_MODULE=1 endif |