/* If you have already X v4l cards, then set this to X. This way thedevicenumbersstaymatched.Example:youhaveaWinTVcard withoutradioandaPVR-350with.Normallythiswouldgivea video1devicetogetherwitharadio0deviceforthePVR.By
setting this to 1 you ensure that radio0 is now also radio1. */ int ivtv_first_minor;
/* Callback for registering extensions */ int (*ivtv_ext_init)(struct ivtv *);
EXPORT_SYMBOL(ivtv_ext_init);
/* add your revision and whatnot here */ staticconststruct pci_device_id ivtv_pci_tbl[] = {
{PCI_VENDOR_ID_ICOMP, PCI_DEVICE_ID_IVTV15,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{PCI_VENDOR_ID_ICOMP, PCI_DEVICE_ID_IVTV16,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{0,}
};
/* Generic utility functions */ int ivtv_msleep_timeout(unsignedint msecs, int intr)
{ int timeout = msecs_to_jiffies(msecs);
do {
set_current_state(intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
timeout = schedule_timeout(timeout); if (intr) { int ret = signal_pending(current);
if (ret) return ret;
}
} while (timeout); return0;
}
/* Hauppauge card? get values from tveeprom */ void ivtv_read_eeprom(struct ivtv *itv, struct tveeprom *tv)
{
u8 eedata[256];
/* Many thanks to Steven Toth from Hauppauge for providing the
model numbers */ switch (tv.model) { /* In a few cases the PCI subsystem IDs do not correctly identifythecard.Abettermethodistocheckthe
model number from the eeprom instead. */ case30012 ... 30039: /* Low profile PVR250 */ case32000 ... 32999: case48000 ... 48099: /* 48??? range are PVR250s with a cx23415 */ case48400 ... 48599:
itv->card = ivtv_get_card(IVTV_CARD_PVR_250); break; case48100 ... 48399: case48600 ... 48999:
itv->card = ivtv_get_card(IVTV_CARD_PVR_350); break; case23000 ... 23999: /* PVR500 */ case25000 ... 25999: /* Low profile PVR150 */ case26000 ... 26999: /* Regular PVR150 */
itv->card = ivtv_get_card(IVTV_CARD_PVR_150); break; case0:
IVTV_ERR("Invalid EEPROM\n"); return; default:
IVTV_ERR("Unknown model %d, defaulting to PVR-150\n", tv.model);
itv->card = ivtv_get_card(IVTV_CARD_PVR_150); break;
}
switch (tv.model) { /* Old style PVR350 (with an saa7114) uses this input for
the tuner. */ case48254:
itv->card = ivtv_get_card(IVTV_CARD_PVR_350_V1); break; default: break;
}
/* If this is a PVR500 then it should be possible to detect whether it is the firstorsecondunitbylookingatthesubsystemdeviceID:isbit4is set,thenitisthesecondunit(accordingtoinfofromHauppauge).
itv->options.newi2c = newi2c; if (tunertype < -1 || tunertype > 1) {
IVTV_WARN("Invalid tunertype argument, will autodetect instead\n");
tunertype = -1;
}
itv->std = ivtv_parse_std(itv); if (itv->std == 0 && tunertype >= 0)
itv->std = tunertype ? V4L2_STD_MN : (V4L2_STD_ALL & ~V4L2_STD_MN);
itv->has_cx23415 = (itv->pdev->device == PCI_DEVICE_ID_IVTV15);
chipname = itv->has_cx23415 ? "cx23415" : "cx23416"; if (itv->options.cardtype == -1) {
IVTV_INFO("Ignore card (detected %s based chip)\n", chipname); return;
} if ((itv->card = ivtv_get_card(itv->options.cardtype - 1))) {
IVTV_INFO("User specified %s card (detected %s based chip)\n",
itv->card->name, chipname);
} elseif (itv->options.cardtype != 0) {
IVTV_ERR("Unknown user specified type, trying to autodetect card\n");
} if (itv->card == NULL) { if (itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE ||
itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE_ALT1 ||
itv->pdev->subsystem_vendor == IVTV_PCI_ID_HAUPPAUGE_ALT2) {
itv->card = ivtv_get_card(itv->has_cx23415 ? IVTV_CARD_PVR_350 : IVTV_CARD_PVR_150);
IVTV_INFO("Autodetected Hauppauge card (%s based)\n",
chipname);
}
} if (itv->card == NULL) { for (i = 0; (itv->card = ivtv_get_card(i)); i++) { if (itv->card->pci_list == NULL) continue; for (j = 0; itv->card->pci_list[j].device; j++) { if (itv->pdev->device !=
itv->card->pci_list[j].device) continue; if (itv->pdev->subsystem_vendor !=
itv->card->pci_list[j].subsystem_vendor) continue; if (itv->pdev->subsystem_device !=
itv->card->pci_list[j].subsystem_device) continue;
IVTV_INFO("Autodetected %s card (%s based)\n",
itv->card->name, chipname); goto done;
}
}
}
done:
if (itv->card == NULL) {
itv->card = ivtv_get_card(IVTV_CARD_PVR_150);
IVTV_ERR("Unknown card: vendor/device: [%04x:%04x]\n",
itv->pdev->vendor, itv->pdev->device);
IVTV_ERR(" subsystem vendor/device: [%04x:%04x]\n",
itv->pdev->subsystem_vendor, itv->pdev->subsystem_device);
IVTV_ERR(" %s based\n", chipname);
IVTV_ERR("Defaulting to %s card\n", itv->card->name);
IVTV_ERR("Please mail the vendor/device and subsystem vendor/device IDs and what kind of\n");
IVTV_ERR("card you have to the linux-media mailinglist (www.linuxtv.org)\n");
IVTV_ERR("Prefix your subject line with [UNKNOWN IVTV CARD].\n");
}
itv->v4l2_cap = itv->card->v4l2_capabilities;
itv->card_name = itv->card->name;
itv->card_i2c = itv->card->i2c;
}
/* Precondition: the ivtv structure has been memset to 0. Only thedevandnumfieldshavebeenfilledin. Noassumptionsonthecardtypemaybemadehere(seeivtv_init_struct2 forthat).
*/ staticint ivtv_init_struct1(struct ivtv *itv)
{
itv->base_addr = pci_resource_start(itv->pdev, 0);
itv->enc_mbox.max_mbox = 2; /* the encoder has 3 mailboxes (0-2) */
itv->dec_mbox.max_mbox = 1; /* the decoder has 2 mailboxes (0-1) */
kthread_init_worker(&itv->irq_worker);
itv->irq_worker_task = kthread_run(kthread_worker_fn, &itv->irq_worker, "%s", itv->v4l2_dev.name); if (IS_ERR(itv->irq_worker_task)) {
IVTV_ERR("Could not create ivtv task\n"); return -1;
} /* must use the FIFO scheduler as it is realtime sensitive */
sched_set_fifo(itv->irq_worker_task);
/* Second initialization part. Here the card type has been
autodetected. */ staticvoid ivtv_init_struct2(struct ivtv *itv)
{ int i;
for (i = 0; i < IVTV_CARD_MAX_VIDEO_INPUTS; i++) if (itv->card->video_inputs[i].video_type == 0) break;
itv->nof_inputs = i; for (i = 0; i < IVTV_CARD_MAX_AUDIO_INPUTS; i++) if (itv->card->audio_inputs[i].audio_type == 0) break;
itv->nof_audio_inputs = i;
if (itv->card->hw_all & IVTV_HW_CX25840) {
itv->vbi.sliced_size = 288; /* multiple of 16, real size = 284 */
} else {
itv->vbi.sliced_size = 64; /* multiple of 16, real size = 52 */
}
/* Find tuner input */ for (i = 0; i < itv->nof_inputs; i++) { if (itv->card->video_inputs[i].video_type ==
IVTV_CARD_INPUT_VID_TUNER) break;
} if (i >= itv->nof_inputs)
i = 0;
itv->active_input = i;
itv->audio_input = itv->card->video_inputs[i].audio_index;
}
/* Check for bus mastering */
pci_read_config_word(pdev, PCI_COMMAND, &cmd); if (!(cmd & PCI_COMMAND_MASTER)) {
IVTV_DEBUG_INFO("Attempting to enable Bus Mastering\n");
pci_set_master(pdev);
pci_read_config_word(pdev, PCI_COMMAND, &cmd); if (!(cmd & PCI_COMMAND_MASTER)) {
IVTV_ERR("Bus Mastering is not enabled\n"); return -ENXIO;
}
}
IVTV_DEBUG_INFO("Bus Mastering Enabled.\n");
if (itv->card->type == IVTV_CARD_CX23416GYC) { /* Several variations of this card exist, detect which card
type should be used. */ if ((hw & (IVTV_HW_UPD64031A | IVTV_HW_UPD6408X)) == 0)
itv->card = ivtv_get_card(IVTV_CARD_CX23416GYC_NOGRYCS); elseif ((hw & IVTV_HW_UPD64031A) == 0)
itv->card = ivtv_get_card(IVTV_CARD_CX23416GYC_NOGR);
} elseif (itv->card->type == IVTV_CARD_GV_MVPRX ||
itv->card->type == IVTV_CARD_GV_MVPRX2E) { /* The crystal frequency of GVMVPRX is 24.576MHz */
v4l2_subdev_call(itv->sd_video, video, s_crystal_freq,
SAA7115_FREQ_24_576_MHZ, SAA7115_FREQ_FL_UCGC);
}
/* map io memory */
IVTV_DEBUG_INFO("attempting ioremap at 0x%llx len 0x%08x\n",
(u64)itv->base_addr + IVTV_ENCODER_OFFSET, IVTV_ENCODER_SIZE);
itv->enc_mem = devm_ioremap(&pdev->dev,
itv->base_addr + IVTV_ENCODER_OFFSET,
IVTV_ENCODER_SIZE); if (!itv->enc_mem) {
IVTV_ERR("ioremap failed. Can't get a window into CX23415/6 encoder memory\n");
IVTV_ERR("Each capture card with a CX23415/6 needs 8 MB of vmalloc address space for this window\n");
IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\n");
IVTV_ERR("Use the vmalloc= kernel command line option to set VmallocTotal to a larger value\n");
retval = -ENOMEM; goto free_worker;
}
if (itv->has_cx23415) {
IVTV_DEBUG_INFO("attempting ioremap at 0x%llx len 0x%08x\n",
(u64)itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE);
itv->dec_mem = devm_ioremap(&pdev->dev,
itv->base_addr + IVTV_DECODER_OFFSET,
IVTV_DECODER_SIZE); if (!itv->dec_mem) {
IVTV_ERR("ioremap failed. Can't get a window into CX23415 decoder memory\n");
IVTV_ERR("Each capture card with a CX23415 needs 8 MB of vmalloc address space for this window\n");
IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\n");
IVTV_ERR("Use the vmalloc= kernel command line option to set VmallocTotal to a larger value\n");
retval = -ENOMEM; goto free_worker;
}
} else {
itv->dec_mem = itv->enc_mem;
}
/* map registers memory */
IVTV_DEBUG_INFO("attempting ioremap at 0x%llx len 0x%08x\n",
(u64)itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE);
itv->reg_mem = devm_ioremap(&pdev->dev,
itv->base_addr + IVTV_REG_OFFSET,
IVTV_REG_SIZE); if (!itv->reg_mem) {
IVTV_ERR("ioremap failed. Can't get a window into CX23415/6 register space\n");
IVTV_ERR("Each capture card with a CX23415/6 needs 64 kB of vmalloc address space for this window\n");
IVTV_ERR("Check the output of 'grep Vmalloc /proc/meminfo'\n");
IVTV_ERR("Use the vmalloc= kernel command line option to set VmallocTotal to a larger value\n");
retval = -ENOMEM; goto free_worker;
}
retval = ivtv_gpio_init(itv); if (retval) goto free_worker;
/* active i2c */
IVTV_DEBUG_INFO("activating i2c...\n"); if (init_ivtv_i2c(itv)) {
IVTV_ERR("Could not initialize i2c\n"); goto free_worker;
}
if (itv->card->hw_all & IVTV_HW_TVEEPROM) { /* Based on the model number the cardtype may be changed.
The PCI IDs are not always reliable. */
ivtv_process_eeprom(itv);
} if (itv->card->comment)
IVTV_INFO("%s", itv->card->comment); if (itv->card->v4l2_capabilities == 0) { /* card was detected but is not supported */
retval = -ENODEV; goto free_i2c;
}
if (itv->std == 0) {
itv->std = V4L2_STD_NTSC_M;
}
if (itv->options.tuner == -1) { int i;
for (i = 0; i < IVTV_CARD_MAX_TUNERS; i++) { if ((itv->std & itv->card->tuners[i].std) == 0) continue;
itv->options.tuner = itv->card->tuners[i].tuner; break;
}
} /* if no tuner was found, then pick the first tuner in the card list */ if (itv->options.tuner == -1 && itv->card->tuners[0].std) {
itv->std = itv->card->tuners[0].std; if (itv->std & V4L2_STD_PAL)
itv->std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H; elseif (itv->std & V4L2_STD_NTSC)
itv->std = V4L2_STD_NTSC_M; elseif (itv->std & V4L2_STD_SECAM)
itv->std = V4L2_STD_SECAM_L;
itv->options.tuner = itv->card->tuners[0].tuner;
} if (itv->options.radio == -1)
itv->options.radio = (itv->card->radio_input.audio_type != 0);
/* The card is now fully identified, continue with card-specific
initialization. */
ivtv_init_struct2(itv);
/* Setup VBI Raw Size. Should be big enough to hold PAL. ItispossibletoswitchbetweenPALandNTSC,soweneedto
take the largest size here. */ /* 1456 is multiple of 16, real size = 1444 */
itv->vbi.raw_size = 1456; /* We use a buffer size of 1/2 of the total size needed for a frame.Thisisactuallyveryuseful,sincewenowreceive afieldatatimeandthatmakes'compressing'therawdata downtosizebystrippingofftheSAVcodesaloteasier. Note:havingtwodifferentbuffersizespreventsstandard
switching on the fly. We need to find a better solution... */
vbi_buf_size = itv->vbi.raw_size * (itv->is_60hz ? 24 : 36) / 2;
itv->stream_buf_size[IVTV_ENC_STREAM_TYPE_VBI] = vbi_buf_size;
itv->stream_buf_size[IVTV_DEC_STREAM_TYPE_VBI] = sizeof(struct v4l2_sliced_vbi_data) * 36;
if (itv->options.radio > 0)
itv->v4l2_cap |= V4L2_CAP_RADIO;
if (itv->options.tuner > -1) { struct tuner_setup setup;
int ivtv_init_on_first_open(struct ivtv *itv)
{ struct v4l2_frequency vf; /* Needed to call ioctls later */ struct ivtv_open_id fh; int fw_retry_count = 3; int video_input;
fh.itv = itv;
fh.type = IVTV_ENC_STREAM_TYPE_MPG;
if (test_bit(IVTV_F_I_FAILED, &itv->i_flags)) return -ENXIO;
if (test_and_set_bit(IVTV_F_I_INITED, &itv->i_flags)) return0;
while (--fw_retry_count > 0) { /* load firmware */ if (ivtv_firmware_init(itv) == 0) break; if (fw_retry_count > 1)
IVTV_WARN("Retry loading firmware\n");
}
if (fw_retry_count == 0) {
set_bit(IVTV_F_I_FAILED, &itv->i_flags); return -ENXIO;
}
/* Try and get firmware versions */
IVTV_DEBUG_INFO("Getting firmware version..\n");
ivtv_firmware_versions(itv);
if (itv->card->hw_all & IVTV_HW_CX25840)
v4l2_subdev_call(itv->sd_video, core, load_fw);
vf.tuner = 0;
vf.type = V4L2_TUNER_ANALOG_TV;
vf.frequency = 6400; /* the tuner 'baseline' frequency */
video_input = itv->active_input;
itv->active_input++; /* Force update of input */
ivtv_s_input(NULL, &fh, video_input);
/* Let the VIDIOC_S_STD ioctl do all the work, keeps the code
in one place. */
itv->std++; /* Force full standard initialization */
itv->std_out = itv->std;
ivtv_s_frequency(NULL, &fh, &vf);
if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) { /* Turn on the TV-out: ivtv_init_mpeg_decoder() initializes thempegdecodersonowthesaa7127receivesaproper
signal. */
ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 1);
ivtv_init_mpeg_decoder(itv);
}
/* On a cx23416 this seems to be able to enable DMA to the chip? */ if (!itv->has_cx23415)
write_reg_sync(0x03, IVTV_REG_DMACONTROL);
ivtv_s_std_enc(itv, itv->tuner_std);
/* Default interrupts enabled. For the PVR350 this includes the decoderVSYNCinterrupt,whichisalwayson.Itisnotonlyused duringdecodingbutalsobytheOSD. SomeoldPVR250cardshadacx23415,sotestingforthatistoo
general. Instead test if the card has video output capability. */ if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT | IVTV_IRQ_DEC_VSYNC);
ivtv_set_osd_alpha(itv);
ivtv_s_std_dec(itv, itv->tuner_std);
} else {
ivtv_clear_irq_mask(itv, IVTV_IRQ_MASK_INIT);
}
if (test_bit(IVTV_F_I_INITED, &itv->i_flags)) { /* Stop all captures */
IVTV_DEBUG_INFO("Stopping all streams\n"); if (atomic_read(&itv->capturing) > 0)
ivtv_stop_all_captures(itv);
/* Stop all decoding */
IVTV_DEBUG_INFO("Stopping decoding\n");
/* Turn off the TV-out */ if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)
ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 0); if (atomic_read(&itv->decoding) > 0) { int type;
if (test_bit(IVTV_F_I_DEC_YUV, &itv->i_flags))
type = IVTV_DEC_STREAM_TYPE_YUV; else
type = IVTV_DEC_STREAM_TYPE_MPG;
ivtv_stop_v4l2_decode_stream(&itv->streams[type],
V4L2_DEC_CMD_STOP_TO_BLACK | V4L2_DEC_CMD_STOP_IMMEDIATELY, 0);
}
ivtv_halt_firmware(itv);
}
/* Note: These symbols are exported because they are used by the ivtvfb
framebuffer module and an infrared module for the IR-blaster. */
EXPORT_SYMBOL(ivtv_set_irq_mask);
EXPORT_SYMBOL(ivtv_api);
EXPORT_SYMBOL(ivtv_vapi);
EXPORT_SYMBOL(ivtv_vapi_result);
EXPORT_SYMBOL(ivtv_clear_irq_mask);
EXPORT_SYMBOL(ivtv_debug); #ifdef CONFIG_VIDEO_ADV_DEBUG
EXPORT_SYMBOL(ivtv_fw_debug); #endif
EXPORT_SYMBOL(ivtv_reset_ir_gpio);
EXPORT_SYMBOL(ivtv_udma_setup);
EXPORT_SYMBOL(ivtv_udma_unmap);
EXPORT_SYMBOL(ivtv_udma_alloc);
EXPORT_SYMBOL(ivtv_udma_prepare);
EXPORT_SYMBOL(ivtv_init_on_first_open);
EXPORT_SYMBOL(ivtv_firmware_check);
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.