Lines Matching refs:pd
42 #include "pd-common.h"
64 s32 send_set_req(struct poseidon *pd, u8 cmdid, s32 param, s32 *cmd_status)
70 if (pd->state & POSEIDON_STATE_DISCONNECT)
82 ret = usb_control_msg(pd->udev,
83 usb_rcvctrlpipe(pd->udev, 0),
104 s32 send_get_req(struct poseidon *pd, u8 cmdid, s32 param,
111 if (pd->state & POSEIDON_STATE_DISCONNECT)
122 ret = usb_control_msg(pd->udev,
123 usb_rcvctrlpipe(pd->udev, 0),
145 struct poseidon *pd = NULL;
155 pd = container_of(node, struct poseidon, device_list);
156 udev = pd->udev;
157 iface = pd->interface;
178 int set_tuner_mode(struct poseidon *pd, unsigned char mode)
182 if (pd->state & POSEIDON_STATE_DISCONNECT)
185 ret = send_set_req(pd, TUNE_MODE_SELECT, mode, &cmd_status);
193 struct poseidon *pd = container_of(kref, struct poseidon, kref);
195 if (!pd)
197 list_del_init(&pd->device_list);
199 pd_dvb_usb_device_cleanup(pd);
200 /* clean_audio_data(&pd->audio_data);*/
202 if (pd->udev) {
203 usb_put_dev(pd->udev);
204 pd->udev = NULL;
206 if (pd->interface) {
207 usb_put_intf(pd->interface);
208 pd->interface = NULL;
210 kfree(pd);
263 static inline void set_map_flags(struct poseidon *pd, struct usb_device *udev)
265 pd->portnum = udev->portnum;
268 static inline int get_autopm_ref(struct poseidon *pd)
270 return pd->video_data.users + pd->vbi_data.users + pd->audio.users
271 + atomic_read(&pd->dvb_data.users) + pd->radio_data.users;
275 static inline struct poseidon *fixup(struct poseidon *pd)
280 count = get_autopm_ref(pd);
281 log("count : %d, ref count : %d", count, get_pm_count(pd));
283 usb_autopm_put_interface(pd->interface);
284 /*usb_autopm_set_interface(pd->interface); */
286 usb_put_dev(pd->udev);
287 usb_put_intf(pd->interface);
288 log("event : %d\n", pd->msg.event);
289 return pd;
294 struct poseidon *pd;
296 list_for_each_entry(pd, &pd_device_list, device_list) {
297 if (pd->portnum == udev->portnum && in_hibernation(pd))
298 return fixup(pd);
304 static inline int is_working(struct poseidon *pd)
306 return get_pm_count(pd) > 0;
311 struct poseidon *pd = get_pd(intf);
313 if (!pd)
315 if (!is_working(pd)) {
316 if (get_pm_count(pd) <= 0 && !in_hibernation(pd)) {
317 pd->msg.event = PM_EVENT_AUTO_SUSPEND;
318 pd->pm_resume = NULL; /* a good guard */
323 pd->msg = msg; /* save it here */
324 logpm(pd);
325 return pd->pm_suspend ? pd->pm_suspend(pd) : 0;
330 struct poseidon *pd = get_pd(intf);
332 if (!pd)
336 if (!is_working(pd)) {
337 if (PM_EVENT_AUTO_SUSPEND == pd->msg.event)
338 pd->msg = PMSG_ON;
341 if (in_hibernation(pd)) {
342 logpm(pd);
345 logpm(pd);
346 return pd->pm_resume ? pd->pm_resume(pd) : 0;
351 struct poseidon *pd = container_of(w, struct poseidon, pm_work);
354 pd->msg.event = 0; /* clear it here */
355 pd->state &= ~POSEIDON_STATE_DISCONNECT;
358 count = get_autopm_ref(pd);
360 usb_autopm_get_interface(pd->interface);
363 logpm(pd);
364 if (pd->pm_resume)
365 pd->pm_resume(pd);
373 static inline void set_map_flags(struct poseidon *pd, struct usb_device *udev)
409 struct poseidon *pd = NULL;
419 pd = find_old_poseidon(udev);
420 if (!pd) {
421 pd = kzalloc(sizeof(*pd), GFP_KERNEL);
422 if (!pd)
424 kref_init(&pd->kref);
425 set_map_flags(pd, udev);
429 pd->udev = usb_get_dev(udev);
430 pd->interface = usb_get_intf(interface);
431 usb_set_intfdata(interface, pd);
436 logpm(pd);
437 mutex_init(&pd->lock);
440 snprintf(pd->v4l2_dev.name, sizeof(pd->v4l2_dev.name), "%s %s",
442 ret = v4l2_device_register(NULL, &pd->v4l2_dev);
445 ret = pd_video_init(pd);
446 poseidon_audio_init(pd);
447 poseidon_fm_init(pd);
448 pd_dvb_usb_device_init(pd);
450 INIT_LIST_HEAD(&pd->device_list);
451 list_add_tail(&pd->device_list, &pd_device_list);
456 pd->udev->autosuspend_delay = HZ * PM_SUSPEND_DELAY;
457 usb_enable_autosuspend(pd->udev);
459 if (in_hibernation(pd)) {
460 INIT_WORK(&pd->pm_work, hibernation_resume);
461 schedule_work(&pd->pm_work);
469 struct poseidon *pd = get_pd(interface);
471 if (!pd)
473 logpm(pd);
474 if (in_hibernation(pd))
477 mutex_lock(&pd->lock);
478 pd->state |= POSEIDON_STATE_DISCONNECT;
479 mutex_unlock(&pd->lock);
482 stop_all_video_stream(pd);
483 dvb_stop_streaming(&pd->dvb_data);
486 v4l2_device_unregister(&pd->v4l2_dev);
490 pd_dvb_usb_device_exit(pd);
491 poseidon_fm_exit(pd);
493 poseidon_audio_free(pd);
494 pd_video_exit(pd);
499 kref_put(&pd->kref, poseidon_delete);