staticint send_control_msg(struct au0828_dev *dev, u16 request, u32 value,
u16 index)
{ int status = -ENODEV;
if (dev->usbdev) {
/* cp must be memory that has been allocated by kmalloc */
status = usb_control_msg(dev->usbdev,
usb_sndctrlpipe(dev->usbdev, 0),
request,
USB_DIR_OUT | USB_TYPE_VENDOR |
USB_RECIP_DEVICE,
value, index, NULL, 0, 1000);
status = min(status, 0);
if (status < 0) {
pr_err("%s() Failed sending control message, error %d.\n",
__func__, status);
}
}
return status;
}
staticint recv_control_msg(struct au0828_dev *dev, u16 request, u32 value,
u16 index, unsignedchar *cp, u16 size)
{ int status = -ENODEV;
mutex_lock(&dev->mutex); if (dev->usbdev) {
status = usb_control_msg(dev->usbdev,
usb_rcvctrlpipe(dev->usbdev, 0),
request,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index,
dev->ctrlmsg, size, 1000);
status = min(status, 0);
if (status < 0) {
pr_err("%s() Failed receiving control message, error %d.\n",
__func__, status);
}
/* the host controller requires heap allocated memory, which
is why we didn't just pass "cp" into usb_control_msg */
memcpy(cp, dev->ctrlmsg, size);
}
mutex_unlock(&dev->mutex); return status;
}
/* there is a small window after disconnect, before dev->usbdevisNULL,forpoll(e.g:IR)trytoaccess thedeviceandfillthedmesgwitherrormessages. Setthestatussopollroutinescancheckandavoid accessafterdisconnect.
*/
set_bit(DEV_DISCONNECTED, &dev->dev_state);
au0828_rc_unregister(dev); /* Digital TV */
au0828_dvb_unregister(dev);
/* Tuner link can be shared by audio, video, and VBI */ switch (owner->function) { case MEDIA_ENT_F_IO_V4L: case MEDIA_ENT_F_AUDIO_CAPTURE: case MEDIA_ENT_F_IO_VBI: if (entity->function == MEDIA_ENT_F_IO_V4L ||
entity->function == MEDIA_ENT_F_AUDIO_CAPTURE ||
entity->function == MEDIA_ENT_F_IO_VBI)
shareable = true; break; case MEDIA_ENT_F_DTV_DEMOD: default: break;
} return shareable;
}
/* Callers should hold graph_mutex */ staticint au0828_enable_source(struct media_entity *entity, struct media_pipeline *pipe)
{ struct media_entity *source, *find_source; struct media_entity *sink; struct media_link *link, *found_link = NULL; int ret = 0; struct media_device *mdev = entity->graph_obj.mdev; struct au0828_dev *dev;
if (!mdev) return -ENODEV;
dev = mdev->source_priv;
/* *ForAudioandV4L2entity,findthelinktowhichdecoder *isthesink.Lookforanactivelinkbetweendecoderand *source(tuner/s-video/Composite),ifoneexists,nothing *todo.Ifnot,lookforanyactivelinksbetweensource *andanyotherentity.Ifoneexists,sourceisbusy.If *sourceisfree,setuplinkandstartpipelinefromsource. *ForDVBFEentity,thesourceforthelinkisthetuner. *Checkiftunerisavailableandsetuplinkandstart *pipeline.
*/ if (entity->function == MEDIA_ENT_F_DTV_DEMOD) {
sink = entity;
find_source = dev->tuner;
} else { /* Analog isn't configured or register failed */ if (!dev->decoder) {
ret = -ENODEV; goto end;
}
/* Is there an active link between sink and source */ if (dev->active_link) { if (dev->active_link_owner == entity) { /* This check is necessary to handle multiple *enable_sourcecallsfromv4l_ioctlsduring *thecourseofvideo/vbiapplicationrun-time.
*/
pr_debug("%s already owns the tuner\n", entity->name);
ret = 0; goto end;
} elseif (au0828_is_link_shareable(dev->active_link_owner,
entity)) { /* Either ALSA or Video own tuner. Sink is the same *forboth.Allowsharingtheactivelinkbetween *theircommonsource(tuner)andsink(decoder). *Startingpipelinebetweensharingentityandsink *willfailwithpipemismatch,whileownerhasan *activepipeline.Switchpipelineownershipfrom *usertoownerwhenownerdisablesthesource.
*/
dev->active_link_shared = true; /* save the user info to use from disable */
dev->active_link_user = entity;
dev->active_link_user_pipe = pipe;
pr_debug("%s owns the tuner %s can share!\n",
dev->active_link_owner->name,
entity->name);
ret = 0; goto end;
} else {
ret = -EBUSY; goto end;
}
}
/* activate link between source and sink and start pipeline */
source = found_link->source->entity;
ret = __media_entity_setup_link(found_link, MEDIA_LNK_FL_ENABLED); if (ret) {
pr_err("Activate link from %s->%s. Error %d\n",
source->name, sink->name, ret); goto end;
}
ret = __media_pipeline_start(entity->pads, pipe); if (ret) {
pr_err("Start Pipeline: %s->%s Error %d\n",
source->name, entity->name, ret);
ret = __media_entity_setup_link(found_link, 0); if (ret)
pr_err("Deactivate link Error %d\n", ret); goto end;
}
/* save link state to allow audio and video share the link *andnotdisablethelinkwhiletheotherisusingit. *active_link_ownerisusedtodeactivatethelink.
*/
dev->active_link = found_link;
dev->active_link_owner = entity;
dev->active_source = source;
dev->active_sink = sink;
/* video owns the link and has users > 1 */ if (!owner_is_audio && dev->users > 1) return;
/* stop pipeline */
__media_pipeline_stop(dev->active_link_owner->pads);
pr_debug("Pipeline stop for %s\n",
dev->active_link_owner->name);
ret = __media_pipeline_start(
dev->active_link_user->pads,
dev->active_link_user_pipe); if (ret) {
pr_err("Start Pipeline: %s->%s %d\n",
dev->active_source->name,
dev->active_link_user->name,
ret); goto deactivate_link;
} /* link user is now the owner */
dev->active_link_owner = dev->active_link_user;
dev->active_link_user = NULL;
dev->active_link_user_pipe = NULL;
dev->active_link_shared = false;
pr_debug("Pipeline started for %s\n",
dev->active_link_owner->name); return;
} elseif (!owner_is_audio && dev->users > 1) /* video/vbi owns the link and has users > 1 */ return;
if (dev->active_link_owner != entity) return;
/* stop pipeline */
__media_pipeline_stop(dev->active_link_owner->pads);
pr_debug("Pipeline stop for %s\n",
dev->active_link_owner->name);
deactivate_link:
ret = __media_entity_setup_link(dev->active_link, 0); if (ret)
pr_err("Deactivate link Error %d\n", ret);
pr_info("Disabled Source: %s->%s->%s Ret %d\n",
dev->active_source->name, dev->active_sink->name,
dev->active_link_owner->name, ret);
/* Analog TV */
retval = au0828_analog_register(dev, interface); if (retval) {
pr_err("%s() au0828_analog_register failed to register on V4L2\n",
__func__);
mutex_unlock(&dev->lock); goto done;
}
/* Digital TV */
retval = au0828_dvb_register(dev); if (retval)
pr_err("%s() au0828_dvb_register failed\n",
__func__);
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.