aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mxb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/mxb.c')
-rw-r--r--drivers/media/video/mxb.c80
1 files changed, 43 insertions, 37 deletions
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index 0b385002350..f0c3968ac7e 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -21,6 +21,8 @@
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/ 22*/
23 23
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25
24#define DEBUG_VARIABLE debug 26#define DEBUG_VARIABLE debug
25 27
26#include <media/saa7146_vv.h> 28#include <media/saa7146_vv.h>
@@ -171,7 +173,7 @@ static int mxb_probe(struct saa7146_dev *dev)
171 173
172 mxb = kzalloc(sizeof(struct mxb), GFP_KERNEL); 174 mxb = kzalloc(sizeof(struct mxb), GFP_KERNEL);
173 if (mxb == NULL) { 175 if (mxb == NULL) {
174 DEB_D(("not enough kernel memory.\n")); 176 DEB_D("not enough kernel memory\n");
175 return -ENOMEM; 177 return -ENOMEM;
176 } 178 }
177 179
@@ -179,7 +181,7 @@ static int mxb_probe(struct saa7146_dev *dev)
179 181
180 saa7146_i2c_adapter_prepare(dev, &mxb->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480); 182 saa7146_i2c_adapter_prepare(dev, &mxb->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
181 if (i2c_add_adapter(&mxb->i2c_adapter) < 0) { 183 if (i2c_add_adapter(&mxb->i2c_adapter) < 0) {
182 DEB_S(("cannot register i2c-device. skipping.\n")); 184 DEB_S("cannot register i2c-device. skipping.\n");
183 kfree(mxb); 185 kfree(mxb);
184 return -EFAULT; 186 return -EFAULT;
185 } 187 }
@@ -200,7 +202,7 @@ static int mxb_probe(struct saa7146_dev *dev)
200 /* check if all devices are present */ 202 /* check if all devices are present */
201 if (!mxb->tea6420_1 || !mxb->tea6420_2 || !mxb->tea6415c || 203 if (!mxb->tea6420_1 || !mxb->tea6420_2 || !mxb->tea6415c ||
202 !mxb->tda9840 || !mxb->saa7111a || !mxb->tuner) { 204 !mxb->tda9840 || !mxb->saa7111a || !mxb->tuner) {
203 printk("mxb: did not find all i2c devices. aborting\n"); 205 pr_err("did not find all i2c devices. aborting\n");
204 i2c_del_adapter(&mxb->i2c_adapter); 206 i2c_del_adapter(&mxb->i2c_adapter);
205 kfree(mxb); 207 kfree(mxb);
206 return -ENODEV; 208 return -ENODEV;
@@ -346,11 +348,11 @@ static int mxb_init_done(struct saa7146_dev* dev)
346 msg.buf = &mxb_saa7740_init[i].data[0]; 348 msg.buf = &mxb_saa7740_init[i].data[0];
347 err = i2c_transfer(&mxb->i2c_adapter, &msg, 1); 349 err = i2c_transfer(&mxb->i2c_adapter, &msg, 1);
348 if (err != 1) { 350 if (err != 1) {
349 DEB_D(("failed to initialize 'sound arena module'.\n")); 351 DEB_D("failed to initialize 'sound arena module'\n");
350 goto err; 352 goto err;
351 } 353 }
352 } 354 }
353 INFO(("'sound arena module' detected.\n")); 355 pr_info("'sound arena module' detected\n");
354 } 356 }
355err: 357err:
356 /* the rest for saa7146: you should definitely set some basic values 358 /* the rest for saa7146: you should definitely set some basic values
@@ -390,7 +392,7 @@ static int vidioc_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *
390 for (i = MAXCONTROLS - 1; i >= 0; i--) { 392 for (i = MAXCONTROLS - 1; i >= 0; i--) {
391 if (mxb_controls[i].id == qc->id) { 393 if (mxb_controls[i].id == qc->id) {
392 *qc = mxb_controls[i]; 394 *qc = mxb_controls[i];
393 DEB_D(("VIDIOC_QUERYCTRL %d.\n", qc->id)); 395 DEB_D("VIDIOC_QUERYCTRL %d\n", qc->id);
394 return 0; 396 return 0;
395 } 397 }
396 } 398 }
@@ -413,11 +415,11 @@ static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *vc)
413 415
414 if (vc->id == V4L2_CID_AUDIO_MUTE) { 416 if (vc->id == V4L2_CID_AUDIO_MUTE) {
415 vc->value = mxb->cur_mute; 417 vc->value = mxb->cur_mute;
416 DEB_D(("VIDIOC_G_CTRL V4L2_CID_AUDIO_MUTE:%d.\n", vc->value)); 418 DEB_D("VIDIOC_G_CTRL V4L2_CID_AUDIO_MUTE:%d\n", vc->value);
417 return 0; 419 return 0;
418 } 420 }
419 421
420 DEB_EE(("VIDIOC_G_CTRL V4L2_CID_AUDIO_MUTE:%d.\n", vc->value)); 422 DEB_EE("VIDIOC_G_CTRL V4L2_CID_AUDIO_MUTE:%d\n", vc->value);
421 return 0; 423 return 0;
422} 424}
423 425
@@ -440,14 +442,14 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc)
440 /* switch the audio-source */ 442 /* switch the audio-source */
441 tea6420_route_line(mxb, vc->value ? 6 : 443 tea6420_route_line(mxb, vc->value ? 6 :
442 video_audio_connect[mxb->cur_input]); 444 video_audio_connect[mxb->cur_input]);
443 DEB_EE(("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d.\n", vc->value)); 445 DEB_EE("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d\n", vc->value);
444 } 446 }
445 return 0; 447 return 0;
446} 448}
447 449
448static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) 450static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
449{ 451{
450 DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index)); 452 DEB_EE("VIDIOC_ENUMINPUT %d\n", i->index);
451 if (i->index >= MXB_INPUTS) 453 if (i->index >= MXB_INPUTS)
452 return -EINVAL; 454 return -EINVAL;
453 memcpy(i, &mxb_inputs[i->index], sizeof(struct v4l2_input)); 455 memcpy(i, &mxb_inputs[i->index], sizeof(struct v4l2_input));
@@ -460,7 +462,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *i)
460 struct mxb *mxb = (struct mxb *)dev->ext_priv; 462 struct mxb *mxb = (struct mxb *)dev->ext_priv;
461 *i = mxb->cur_input; 463 *i = mxb->cur_input;
462 464
463 DEB_EE(("VIDIOC_G_INPUT %d.\n", *i)); 465 DEB_EE("VIDIOC_G_INPUT %d\n", *i);
464 return 0; 466 return 0;
465} 467}
466 468
@@ -471,7 +473,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
471 int err = 0; 473 int err = 0;
472 int i = 0; 474 int i = 0;
473 475
474 DEB_EE(("VIDIOC_S_INPUT %d.\n", input)); 476 DEB_EE("VIDIOC_S_INPUT %d\n", input);
475 477
476 if (input >= MXB_INPUTS) 478 if (input >= MXB_INPUTS)
477 return -EINVAL; 479 return -EINVAL;
@@ -514,7 +516,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
514 516
515 /* switch video in saa7111a */ 517 /* switch video in saa7111a */
516 if (saa7111a_call(mxb, video, s_routing, i, SAA7111_FMT_CCIR, 0)) 518 if (saa7111a_call(mxb, video, s_routing, i, SAA7111_FMT_CCIR, 0))
517 printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a.\n"); 519 pr_err("VIDIOC_S_INPUT: could not address saa7111a\n");
518 520
519 /* switch the audio-source only if necessary */ 521 /* switch the audio-source only if necessary */
520 if (0 == mxb->cur_mute) 522 if (0 == mxb->cur_mute)
@@ -529,11 +531,12 @@ static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *t)
529 struct mxb *mxb = (struct mxb *)dev->ext_priv; 531 struct mxb *mxb = (struct mxb *)dev->ext_priv;
530 532
531 if (t->index) { 533 if (t->index) {
532 DEB_D(("VIDIOC_G_TUNER: channel %d does not have a tuner attached.\n", t->index)); 534 DEB_D("VIDIOC_G_TUNER: channel %d does not have a tuner attached\n",
535 t->index);
533 return -EINVAL; 536 return -EINVAL;
534 } 537 }
535 538
536 DEB_EE(("VIDIOC_G_TUNER: %d\n", t->index)); 539 DEB_EE("VIDIOC_G_TUNER: %d\n", t->index);
537 540
538 memset(t, 0, sizeof(*t)); 541 memset(t, 0, sizeof(*t));
539 strlcpy(t->name, "TV Tuner", sizeof(t->name)); 542 strlcpy(t->name, "TV Tuner", sizeof(t->name));
@@ -550,7 +553,8 @@ static int vidioc_s_tuner(struct file *file, void *fh, struct v4l2_tuner *t)
550 struct mxb *mxb = (struct mxb *)dev->ext_priv; 553 struct mxb *mxb = (struct mxb *)dev->ext_priv;
551 554
552 if (t->index) { 555 if (t->index) {
553 DEB_D(("VIDIOC_S_TUNER: channel %d does not have a tuner attached.\n", t->index)); 556 DEB_D("VIDIOC_S_TUNER: channel %d does not have a tuner attached\n",
557 t->index);
554 return -EINVAL; 558 return -EINVAL;
555 } 559 }
556 560
@@ -564,14 +568,14 @@ static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency
564 struct mxb *mxb = (struct mxb *)dev->ext_priv; 568 struct mxb *mxb = (struct mxb *)dev->ext_priv;
565 569
566 if (mxb->cur_input) { 570 if (mxb->cur_input) {
567 DEB_D(("VIDIOC_G_FREQ: channel %d does not have a tuner!\n", 571 DEB_D("VIDIOC_G_FREQ: channel %d does not have a tuner!\n",
568 mxb->cur_input)); 572 mxb->cur_input);
569 return -EINVAL; 573 return -EINVAL;
570 } 574 }
571 575
572 *f = mxb->cur_freq; 576 *f = mxb->cur_freq;
573 577
574 DEB_EE(("VIDIOC_G_FREQ: freq:0x%08x.\n", mxb->cur_freq.frequency)); 578 DEB_EE("VIDIOC_G_FREQ: freq:0x%08x\n", mxb->cur_freq.frequency);
575 return 0; 579 return 0;
576} 580}
577 581
@@ -588,12 +592,13 @@ static int vidioc_s_frequency(struct file *file, void *fh, struct v4l2_frequency
588 return -EINVAL; 592 return -EINVAL;
589 593
590 if (mxb->cur_input) { 594 if (mxb->cur_input) {
591 DEB_D(("VIDIOC_S_FREQ: channel %d does not have a tuner!\n", mxb->cur_input)); 595 DEB_D("VIDIOC_S_FREQ: channel %d does not have a tuner!\n",
596 mxb->cur_input);
592 return -EINVAL; 597 return -EINVAL;
593 } 598 }
594 599
595 mxb->cur_freq = *f; 600 mxb->cur_freq = *f;
596 DEB_EE(("VIDIOC_S_FREQUENCY: freq:0x%08x.\n", mxb->cur_freq.frequency)); 601 DEB_EE("VIDIOC_S_FREQUENCY: freq:0x%08x\n", mxb->cur_freq.frequency);
597 602
598 /* tune in desired frequency */ 603 /* tune in desired frequency */
599 tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq); 604 tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq);
@@ -612,18 +617,18 @@ static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a)
612 struct mxb *mxb = (struct mxb *)dev->ext_priv; 617 struct mxb *mxb = (struct mxb *)dev->ext_priv;
613 618
614 if (a->index > MXB_INPUTS) { 619 if (a->index > MXB_INPUTS) {
615 DEB_D(("VIDIOC_G_AUDIO %d out of range.\n", a->index)); 620 DEB_D("VIDIOC_G_AUDIO %d out of range\n", a->index);
616 return -EINVAL; 621 return -EINVAL;
617 } 622 }
618 623
619 DEB_EE(("VIDIOC_G_AUDIO %d.\n", a->index)); 624 DEB_EE("VIDIOC_G_AUDIO %d\n", a->index);
620 memcpy(a, &mxb_audios[video_audio_connect[mxb->cur_input]], sizeof(struct v4l2_audio)); 625 memcpy(a, &mxb_audios[video_audio_connect[mxb->cur_input]], sizeof(struct v4l2_audio));
621 return 0; 626 return 0;
622} 627}
623 628
624static int vidioc_s_audio(struct file *file, void *fh, struct v4l2_audio *a) 629static int vidioc_s_audio(struct file *file, void *fh, struct v4l2_audio *a)
625{ 630{
626 DEB_D(("VIDIOC_S_AUDIO %d.\n", a->index)); 631 DEB_D("VIDIOC_S_AUDIO %d\n", a->index);
627 return 0; 632 return 0;
628} 633}
629 634
@@ -655,11 +660,11 @@ static long vidioc_default(struct file *file, void *fh, bool valid_prio,
655 int i = *(int *)arg; 660 int i = *(int *)arg;
656 661
657 if (i < 0 || i >= MXB_AUDIOS) { 662 if (i < 0 || i >= MXB_AUDIOS) {
658 DEB_D(("illegal argument to MXB_S_AUDIO_CD: i:%d.\n", i)); 663 DEB_D("invalid argument to MXB_S_AUDIO_CD: i:%d\n", i);
659 return -EINVAL; 664 return -EINVAL;
660 } 665 }
661 666
662 DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n", i)); 667 DEB_EE("MXB_S_AUDIO_CD: i:%d\n", i);
663 668
664 tea6420_route_cd(mxb, i); 669 tea6420_route_cd(mxb, i);
665 return 0; 670 return 0;
@@ -669,17 +674,18 @@ static long vidioc_default(struct file *file, void *fh, bool valid_prio,
669 int i = *(int *)arg; 674 int i = *(int *)arg;
670 675
671 if (i < 0 || i >= MXB_AUDIOS) { 676 if (i < 0 || i >= MXB_AUDIOS) {
672 DEB_D(("illegal argument to MXB_S_AUDIO_LINE: i:%d.\n", i)); 677 DEB_D("invalid argument to MXB_S_AUDIO_LINE: i:%d\n",
678 i);
673 return -EINVAL; 679 return -EINVAL;
674 } 680 }
675 681
676 DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n", i)); 682 DEB_EE("MXB_S_AUDIO_LINE: i:%d\n", i);
677 tea6420_route_line(mxb, i); 683 tea6420_route_line(mxb, i);
678 return 0; 684 return 0;
679 } 685 }
680 default: 686 default:
681/* 687/*
682 DEB2(printk("does not handle this ioctl.\n")); 688 DEB2(pr_err("does not handle this ioctl\n"));
683*/ 689*/
684 return -ENOIOCTLCMD; 690 return -ENOIOCTLCMD;
685 } 691 }
@@ -693,7 +699,7 @@ static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data
693{ 699{
694 struct mxb *mxb; 700 struct mxb *mxb;
695 701
696 DEB_EE(("dev:%p\n", dev)); 702 DEB_EE("dev:%p\n", dev);
697 703
698 saa7146_vv_init(dev, &vv_data); 704 saa7146_vv_init(dev, &vv_data);
699 if (mxb_probe(dev)) { 705 if (mxb_probe(dev)) {
@@ -720,7 +726,7 @@ static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data
720#endif 726#endif
721 vv_data.ops.vidioc_default = vidioc_default; 727 vv_data.ops.vidioc_default = vidioc_default;
722 if (saa7146_register_device(&mxb->video_dev, dev, "mxb", VFL_TYPE_GRABBER)) { 728 if (saa7146_register_device(&mxb->video_dev, dev, "mxb", VFL_TYPE_GRABBER)) {
723 ERR(("cannot register capture v4l2 device. skipping.\n")); 729 ERR("cannot register capture v4l2 device. skipping.\n");
724 saa7146_vv_release(dev); 730 saa7146_vv_release(dev);
725 return -1; 731 return -1;
726 } 732 }
@@ -728,11 +734,11 @@ static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data
728 /* initialization stuff (vbi) (only for revision > 0 and for extensions which want it)*/ 734 /* initialization stuff (vbi) (only for revision > 0 and for extensions which want it)*/
729 if (MXB_BOARD_CAN_DO_VBI(dev)) { 735 if (MXB_BOARD_CAN_DO_VBI(dev)) {
730 if (saa7146_register_device(&mxb->vbi_dev, dev, "mxb", VFL_TYPE_VBI)) { 736 if (saa7146_register_device(&mxb->vbi_dev, dev, "mxb", VFL_TYPE_VBI)) {
731 ERR(("cannot register vbi v4l2 device. skipping.\n")); 737 ERR("cannot register vbi v4l2 device. skipping.\n");
732 } 738 }
733 } 739 }
734 740
735 printk("mxb: found Multimedia eXtension Board #%d.\n", mxb_num); 741 pr_info("found Multimedia eXtension Board #%d\n", mxb_num);
736 742
737 mxb_num++; 743 mxb_num++;
738 mxb_init_done(dev); 744 mxb_init_done(dev);
@@ -743,7 +749,7 @@ static int mxb_detach(struct saa7146_dev *dev)
743{ 749{
744 struct mxb *mxb = (struct mxb *)dev->ext_priv; 750 struct mxb *mxb = (struct mxb *)dev->ext_priv;
745 751
746 DEB_EE(("dev:%p\n", dev)); 752 DEB_EE("dev:%p\n", dev);
747 753
748 saa7146_unregister_device(&mxb->video_dev,dev); 754 saa7146_unregister_device(&mxb->video_dev,dev);
749 if (MXB_BOARD_CAN_DO_VBI(dev)) 755 if (MXB_BOARD_CAN_DO_VBI(dev))
@@ -765,7 +771,7 @@ static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standa
765 if (V4L2_STD_PAL_I == standard->id) { 771 if (V4L2_STD_PAL_I == standard->id) {
766 v4l2_std_id std = V4L2_STD_PAL_I; 772 v4l2_std_id std = V4L2_STD_PAL_I;
767 773
768 DEB_D(("VIDIOC_S_STD: setting mxb for PAL_I.\n")); 774 DEB_D("VIDIOC_S_STD: setting mxb for PAL_I\n");
769 /* set the 7146 gpio register -- I don't know what this does exactly */ 775 /* set the 7146 gpio register -- I don't know what this does exactly */
770 saa7146_write(dev, GPIO_CTRL, 0x00404050); 776 saa7146_write(dev, GPIO_CTRL, 0x00404050);
771 /* unset the 7111 gpio register -- I don't know what this does exactly */ 777 /* unset the 7111 gpio register -- I don't know what this does exactly */
@@ -774,7 +780,7 @@ static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standa
774 } else { 780 } else {
775 v4l2_std_id std = V4L2_STD_PAL_BG; 781 v4l2_std_id std = V4L2_STD_PAL_BG;
776 782
777 DEB_D(("VIDIOC_S_STD: setting mxb for PAL/NTSC/SECAM.\n")); 783 DEB_D("VIDIOC_S_STD: setting mxb for PAL/NTSC/SECAM\n");
778 /* set the 7146 gpio register -- I don't know what this does exactly */ 784 /* set the 7146 gpio register -- I don't know what this does exactly */
779 saa7146_write(dev, GPIO_CTRL, 0x00404050); 785 saa7146_write(dev, GPIO_CTRL, 0x00404050);
780 /* set the 7111 gpio register -- I don't know what this does exactly */ 786 /* set the 7111 gpio register -- I don't know what this does exactly */
@@ -852,7 +858,7 @@ static struct saa7146_extension extension = {
852static int __init mxb_init_module(void) 858static int __init mxb_init_module(void)
853{ 859{
854 if (saa7146_register_extension(&extension)) { 860 if (saa7146_register_extension(&extension)) {
855 DEB_S(("failed to register extension.\n")); 861 DEB_S("failed to register extension\n");
856 return -ENODEV; 862 return -ENODEV;
857 } 863 }
858 864