/* If you have already X v4l cards, then set this to X. This way the device numbers stay matched. Example: you have a WinTV card without radio and a Compro H900 with. Normally this would give a video1 device together with a radio0 device for the Compro. By
setting this to 1 you ensure that radio0 is now also radio1. */ int cx18_first_minor;
/* Callback for registering extensions */ int (*cx18_ext_init)(struct cx18 *);
EXPORT_SYMBOL(cx18_ext_init);
/* add your revision and whatnot here */ staticconststruct pci_device_id cx18_pci_tbl[] = {
{PCI_VENDOR_ID_CX, PCI_DEVICE_ID_CX23418,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0,}
};
staticvoid cx18_eeprom_dump(struct cx18 *cx, unsignedchar *eedata, int len)
{ int i;
CX18_INFO("eeprom dump:\n"); for (i = 0; i < len; i++) { if (0 == (i % 16))
CX18_INFO("eeprom %02x:", i);
printk(KERN_CONT " %02x", eedata[i]); if (15 == (i % 16))
printk(KERN_CONT "\n");
}
}
/* Many thanks to Steven Toth from Hauppauge for providing the
model numbers */ /* Note: the Samsung memory models cannot be reliably determined from the model number. Use the cardtype module option if you
have one of these preproduction models. */ switch (tv.model) { case 74301: /* Retail models */ case 74321: case 74351: /* OEM models */ case 74361: /* Digital side is s5h1411/tda18271 */
cx->card = cx18_get_card(CX18_CARD_HVR_1600_S5H1411); break; case 74021: /* Retail models */ case 74031: case 74041: case 74141: case 74541: /* OEM models */ case 74551: case 74591: case 74651: case 74691: case 74751: case 74891: /* Digital side is s5h1409/mxl5005s */
cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); break; case 0x718: return; case 0xffffffff:
CX18_INFO("Unknown EEPROM encoding\n"); return; case 0:
CX18_ERR("Invalid EEPROM\n"); return; default:
CX18_ERR("Unknown model %d, defaulting to original HVR-1600 (cardtype=1)\n",
tv.model);
cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); break;
}
cx->stream_buf_size[CX18_ENC_STREAM_TYPE_TS] = enc_ts_bufsize;
cx->stream_buf_size[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_bufsize;
cx->stream_buf_size[CX18_ENC_STREAM_TYPE_IDX] = enc_idx_bufsize;
cx->stream_buf_size[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_bufsize;
cx->stream_buf_size[CX18_ENC_STREAM_TYPE_VBI] = VBI_ACTIVE_SAMPLES * 36;
cx->stream_buf_size[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_bufsize;
cx->stream_buf_size[CX18_ENC_STREAM_TYPE_RAD] = 0; /* control no data */
/* Ensure stream_buffers & stream_buf_size are valid */ for (i = 0; i < CX18_MAX_STREAMS; i++) { if (cx->stream_buffers[i] == 0 || /* User said 0 buffers */
cx->options.megabytes[i] <= 0 || /* User said 0 MB total */
cx->stream_buf_size[i] <= 0) { /* User said buf size 0 */
cx->options.megabytes[i] = 0;
cx->stream_buffers[i] = 0;
cx->stream_buf_size[i] = 0; continue;
} /* * YUV is a special case where the stream_buf_size needs to be * an integral multiple of 33.75 kB (storage for 32 screens * lines to maintain alignment in case of lost buffers). * * IDX is a special case where the stream_buf_size should be * an integral multiple of 1.5 kB (storage for 64 index entries * to maintain alignment in case of lost buffers). *
*/ if (i == CX18_ENC_STREAM_TYPE_YUV) {
cx->stream_buf_size[i] *= 1024;
cx->stream_buf_size[i] -=
(cx->stream_buf_size[i] % CX18_UNIT_ENC_YUV_BUFSIZE);
if (cx->stream_buf_size[i] < CX18_UNIT_ENC_IDX_BUFSIZE)
cx->stream_buf_size[i] =
CX18_UNIT_ENC_IDX_BUFSIZE;
} /* * YUV and IDX are special cases where the stream_buf_size is * now in bytes. * VBI is a special case where the stream_buf_size is fixed * and already in bytes
*/ if (i == CX18_ENC_STREAM_TYPE_VBI ||
i == CX18_ENC_STREAM_TYPE_YUV ||
i == CX18_ENC_STREAM_TYPE_IDX) { if (cx->stream_buffers[i] < 0) {
cx->stream_buffers[i] =
cx->options.megabytes[i] * 1024 * 1024
/ cx->stream_buf_size[i];
} else { /* N.B. This might round down to 0 */
cx->options.megabytes[i] =
cx->stream_buffers[i]
* cx->stream_buf_size[i]/(1024 * 1024);
}
} else { /* All other streams have stream_buf_size in kB here */ if (cx->stream_buffers[i] < 0) {
cx->stream_buffers[i] =
cx->options.megabytes[i] * 1024
/ cx->stream_buf_size[i];
} else { /* N.B. This might round down to 0 */
cx->options.megabytes[i] =
cx->stream_buffers[i]
* cx->stream_buf_size[i] / 1024;
} /* convert from kB to bytes */
cx->stream_buf_size[i] *= 1024;
}
CX18_DEBUG_INFO("Stream type %d options: %d MB, %d buffers, %d bytes\n",
i, cx->options.megabytes[i],
cx->stream_buffers[i], cx->stream_buf_size[i]);
}
cx->std = cx18_parse_std(cx); if (cx->options.cardtype == -1) {
CX18_INFO("Ignore card\n"); return;
}
cx->card = cx18_get_card(cx->options.cardtype - 1); if (cx->card)
CX18_INFO("User specified %s card\n", cx->card->name); elseif (cx->options.cardtype != 0)
CX18_ERR("Unknown user specified type, trying to autodetect card\n"); if (!cx->card) { if (cx->pci_dev->subsystem_vendor == CX18_PCI_ID_HAUPPAUGE) {
cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
CX18_INFO("Autodetected Hauppauge card\n");
}
} if (!cx->card) { for (i = 0; (cx->card = cx18_get_card(i)); i++) { if (!cx->card->pci_list) continue; for (j = 0; cx->card->pci_list[j].device; j++) { if (cx->pci_dev->device !=
cx->card->pci_list[j].device) continue; if (cx->pci_dev->subsystem_vendor !=
cx->card->pci_list[j].subsystem_vendor) continue; if (cx->pci_dev->subsystem_device !=
cx->card->pci_list[j].subsystem_device) continue;
CX18_INFO("Autodetected %s card\n", cx->card->name); goto done;
}
}
}
done:
if (!cx->card) {
cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
CX18_ERR("Unknown card: vendor/device: [%04x:%04x]\n",
cx->pci_dev->vendor, cx->pci_dev->device);
CX18_ERR(" subsystem vendor/device: [%04x:%04x]\n",
cx->pci_dev->subsystem_vendor,
cx->pci_dev->subsystem_device);
CX18_ERR("Defaulting to %s card\n", cx->card->name);
CX18_ERR("Please mail the vendor/device and subsystem vendor/device IDs and what kind of\n");
CX18_ERR("card you have to the linux-media mailinglist (www.linuxtv.org)\n");
CX18_ERR("Prefix your subject line with [UNKNOWN CX18 CARD].\n");
}
cx->v4l2_cap = cx->card->v4l2_capabilities;
cx->card_name = cx->card->name;
cx->card_i2c = cx->card->i2c;
}
staticvoid cx18_init_in_work_orders(struct cx18 *cx)
{ int i; for (i = 0; i < CX18_MAX_IN_WORK_ORDERS; i++) {
cx->in_work_order[i].cx = cx;
cx->in_work_order[i].str = cx->epu_debug_str;
INIT_WORK(&cx->in_work_order[i].work, cx18_in_work_handler);
}
}
/* Precondition: the cx18 structure has been memset to 0. Only the dev and instance fields have been filled in. No assumptions on the card type may be made here (see cx18_init_struct2 for that).
*/ staticint cx18_init_struct1(struct cx18 *cx)
{ int ret;
/* Second initialization part. Here the card type has been
autodetected. */ staticvoid cx18_init_struct2(struct cx18 *cx)
{ int i;
for (i = 0; i < CX18_CARD_MAX_VIDEO_INPUTS; i++) if (cx->card->video_inputs[i].video_type == 0) break;
cx->nof_inputs = i; for (i = 0; i < CX18_CARD_MAX_AUDIO_INPUTS; i++) if (cx->card->audio_inputs[i].audio_type == 0) break;
cx->nof_audio_inputs = i;
/* Find tuner input */ for (i = 0; i < cx->nof_inputs; i++) { if (cx->card->video_inputs[i].video_type ==
CX18_CARD_INPUT_VID_TUNER) break;
} if (i == cx->nof_inputs)
i = 0;
cx->active_input = i;
cx->audio_input = cx->card->video_inputs[i].audio_index;
}
for (i = 0, device = 1; i < 32; i++, device <<= 1) {
if (!(device & hw)) continue;
switch (device) { case CX18_HW_DVB: case CX18_HW_TVEEPROM: /* These subordinate devices do not use probing */
cx->hw_flags |= device; break; case CX18_HW_418_AV: /* The A/V decoder gets probed earlier to set PLLs */ /* Just note that the card uses it (i.e. has analog) */
cx->hw_flags |= device; break; case CX18_HW_GPIO_RESET_CTRL: /* * The Reset Controller gets probed and added to * hw_flags earlier for i2c adapter/bus initialization
*/ break; case CX18_HW_GPIO_MUX: if (cx18_gpio_register(cx, device) == 0)
cx->hw_flags |= device; break; default: if (cx18_i2c_register(cx, i) == 0)
cx->hw_flags |= device; break;
}
}
if (cx->hw_flags & CX18_HW_418_AV)
cx->sd_av = cx18_find_hw(cx, CX18_HW_418_AV);
if (cx->card->hw_muxer != 0)
cx->sd_extmux = cx18_find_hw(cx, cx->card->hw_muxer);
}
staticint cx18_probe(struct pci_dev *pci_dev, conststruct pci_device_id *pci_id)
{ int retval = 0; int i;
u32 devtype; struct cx18 *cx;
/* FIXME - module parameter arrays constrain max instances */
i = atomic_inc_return(&cx18_instance) - 1; if (i >= CX18_MAX_CARDS) {
printk(KERN_ERR "cx18: cannot manage card %d, driver has a limit of 0 - %d\n",
i, CX18_MAX_CARDS - 1); return -ENOMEM;
}
cx = kzalloc(sizeof(*cx), GFP_KERNEL); if (!cx) return -ENOMEM;
/* Initialize integrated A/V decoder early to set PLLs, just in case */
retval = cx18_av_probe(cx); if (retval) {
CX18_ERR("Could not register A/V decoder subdevice\n"); goto free_map;
}
/* Initialize GPIO Reset Controller to do chip resets during i2c init */ if (cx->card->hw_all & CX18_HW_GPIO_RESET_CTRL) { if (cx18_gpio_register(cx, CX18_HW_GPIO_RESET_CTRL) != 0)
CX18_WARN("Could not register GPIO reset controllersubdevice; proceeding anyway.\n"); else
cx->hw_flags |= CX18_HW_GPIO_RESET_CTRL;
}
/* active i2c */
CX18_DEBUG_INFO("activating i2c...\n");
retval = init_cx18_i2c(cx); if (retval) {
CX18_ERR("Could not initialize i2c\n"); goto free_map;
}
if (cx->card->hw_all & CX18_HW_TVEEPROM) { /* Based on the model number the cardtype may be changed.
The PCI IDs are not always reliable. */ conststruct cx18_card *orig_card = cx->card;
cx18_process_eeprom(cx);
if (cx->card != orig_card) { /* Changed the cardtype; re-reset the I2C chips */
cx18_gpio_init(cx);
cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL,
core, reset, (u32) CX18_GPIO_RESET_I2C);
}
} if (cx->card->comment)
CX18_INFO("%s", cx->card->comment); if (cx->card->v4l2_capabilities == 0) {
retval = -ENODEV; goto free_i2c;
}
cx18_init_memory(cx);
cx18_init_scb(cx);
/* The tuner is fixed to the standard. The other inputs (e.g. S-Video)
are not. */
cx->tuner_std = cx->std; if (cx->std == V4L2_STD_ALL)
cx->std = V4L2_STD_NTSC_M;
retval = cx18_streams_setup(cx); if (retval) {
CX18_ERR("Error %d setting up streams\n", retval); goto free_irq;
}
retval = cx18_streams_register(cx); if (retval) {
CX18_ERR("Error %d registering devices\n", retval); goto free_streams;
}
/* * Init the firmware twice to work around a silicon bug * with the digital TS. * * The second firmware load requires us to normalize the APU state, * or the audio for the first analog capture will be badly incorrect. * * I can't seem to call APU_RESETAI and have it succeed without the * APU capturing audio, so we start and stop it here to do the reset
*/
fw_retry_count = 3; while (--fw_retry_count > 0) { /* load firmware */ if (cx18_firmware_init(cx) == 0) break; if (fw_retry_count > 1)
CX18_WARN("Retry loading firmware\n");
}
if (fw_retry_count == 0) {
set_bit(CX18_F_I_FAILED, &cx->i_flags); return -ENXIO;
}
/* * The second firmware load requires us to normalize the APU state, * or the audio for the first analog capture will be badly incorrect. * * I can't seem to call APU_RESETAI and have it succeed without the * APU capturing audio, so we start and stop it here to do the reset
*/
/* Init the A/V decoder, if it hasn't been already */
v4l2_subdev_call(cx->sd_av, core, load_fw);
vf.tuner = 0;
vf.type = V4L2_TUNER_ANALOG_TV;
vf.frequency = 6400; /* the tuner 'baseline' frequency */
/* Set initial frequency. For PAL/SECAM broadcasts no
'default' channel exists AFAIK. */ if (cx->std == V4L2_STD_NTSC_M_JP)
vf.frequency = 1460; /* ch. 1 91250*16/1000 */ elseif (cx->std & V4L2_STD_NTSC_M)
vf.frequency = 1076; /* ch. 4 67250*16/1000 */
video_input = cx->active_input;
cx->active_input++; /* Force update of input */
cx18_s_input(NULL, &fh, video_input);
/* Let the VIDIOC_S_STD ioctl do all the work, keeps the code
in one place. */
cx->std++; /* Force full standard initialization */
std = (cx->tuner_std == V4L2_STD_ALL) ? V4L2_STD_NTSC_M : cx->tuner_std;
cx18_s_std(NULL, &fh, std);
cx18_s_frequency(NULL, &fh, &vf); return 0;
}
staticvoid cx18_cancel_in_work_orders(struct cx18 *cx)
{ int i; for (i = 0; i < CX18_MAX_IN_WORK_ORDERS; i++)
cancel_work_sync(&cx->in_work_order[i].work);
}
staticvoid cx18_cancel_out_work_orders(struct cx18 *cx)
{ int i; for (i = 0; i < CX18_MAX_STREAMS; i++) if (cx->streams[i].video_dev.v4l2_dev)
cancel_work_sync(&cx->streams[i].out_work_order);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.