diff options
Diffstat (limited to 'drivers/media/video/saa7115.c')
-rw-r--r-- | drivers/media/video/saa7115.c | 87 |
1 files changed, 36 insertions, 51 deletions
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c index cf530b94cd1..6cc13311bc2 100644 --- a/drivers/media/video/saa7115.c +++ b/drivers/media/video/saa7115.c | |||
@@ -47,25 +47,10 @@ MODULE_AUTHOR("Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, Hans Verkuil"); | |||
47 | MODULE_LICENSE("GPL"); | 47 | MODULE_LICENSE("GPL"); |
48 | 48 | ||
49 | static int debug = 0; | 49 | static int debug = 0; |
50 | module_param(debug, int, 0644); | 50 | module_param(debug, bool, 0644); |
51 | 51 | ||
52 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 52 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
53 | 53 | ||
54 | #define saa7115_dbg(fmt,arg...) \ | ||
55 | do { \ | ||
56 | if (debug) \ | ||
57 | printk(KERN_INFO "%s debug %d-%04x: " fmt, \ | ||
58 | client->driver->driver.name, \ | ||
59 | i2c_adapter_id(client->adapter), client->addr , ## arg); \ | ||
60 | } while (0) | ||
61 | |||
62 | #define saa7115_err(fmt, arg...) do { \ | ||
63 | printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ | ||
64 | i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) | ||
65 | #define saa7115_info(fmt, arg...) do { \ | ||
66 | printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ | ||
67 | i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) | ||
68 | |||
69 | static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END }; | 54 | static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END }; |
70 | 55 | ||
71 | 56 | ||
@@ -564,7 +549,7 @@ static int saa7115_set_audio_clock_freq(struct i2c_client *client, u32 freq) | |||
564 | u32 hz; | 549 | u32 hz; |
565 | u64 f; | 550 | u64 f; |
566 | 551 | ||
567 | saa7115_dbg("set audio clock freq: %d\n", freq); | 552 | v4l_dbg(1, client, "set audio clock freq: %d\n", freq); |
568 | 553 | ||
569 | /* sanity check */ | 554 | /* sanity check */ |
570 | if (freq < 32000 || freq > 48000) | 555 | if (freq < 32000 || freq > 48000) |
@@ -599,7 +584,7 @@ static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *c | |||
599 | switch (ctrl->id) { | 584 | switch (ctrl->id) { |
600 | case V4L2_CID_BRIGHTNESS: | 585 | case V4L2_CID_BRIGHTNESS: |
601 | if (ctrl->value < 0 || ctrl->value > 255) { | 586 | if (ctrl->value < 0 || ctrl->value > 255) { |
602 | saa7115_err("invalid brightness setting %d\n", ctrl->value); | 587 | v4l_err(client, "invalid brightness setting %d\n", ctrl->value); |
603 | return -ERANGE; | 588 | return -ERANGE; |
604 | } | 589 | } |
605 | 590 | ||
@@ -609,7 +594,7 @@ static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *c | |||
609 | 594 | ||
610 | case V4L2_CID_CONTRAST: | 595 | case V4L2_CID_CONTRAST: |
611 | if (ctrl->value < 0 || ctrl->value > 127) { | 596 | if (ctrl->value < 0 || ctrl->value > 127) { |
612 | saa7115_err("invalid contrast setting %d\n", ctrl->value); | 597 | v4l_err(client, "invalid contrast setting %d\n", ctrl->value); |
613 | return -ERANGE; | 598 | return -ERANGE; |
614 | } | 599 | } |
615 | 600 | ||
@@ -619,7 +604,7 @@ static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *c | |||
619 | 604 | ||
620 | case V4L2_CID_SATURATION: | 605 | case V4L2_CID_SATURATION: |
621 | if (ctrl->value < 0 || ctrl->value > 127) { | 606 | if (ctrl->value < 0 || ctrl->value > 127) { |
622 | saa7115_err("invalid saturation setting %d\n", ctrl->value); | 607 | v4l_err(client, "invalid saturation setting %d\n", ctrl->value); |
623 | return -ERANGE; | 608 | return -ERANGE; |
624 | } | 609 | } |
625 | 610 | ||
@@ -629,7 +614,7 @@ static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *c | |||
629 | 614 | ||
630 | case V4L2_CID_HUE: | 615 | case V4L2_CID_HUE: |
631 | if (ctrl->value < -127 || ctrl->value > 127) { | 616 | if (ctrl->value < -127 || ctrl->value > 127) { |
632 | saa7115_err("invalid hue setting %d\n", ctrl->value); | 617 | v4l_err(client, "invalid hue setting %d\n", ctrl->value); |
633 | return -ERANGE; | 618 | return -ERANGE; |
634 | } | 619 | } |
635 | 620 | ||
@@ -685,10 +670,10 @@ static void saa7115_set_v4lstd(struct i2c_client *client, v4l2_std_id std) | |||
685 | 670 | ||
686 | // This works for NTSC-M, SECAM-L and the 50Hz PAL variants. | 671 | // This works for NTSC-M, SECAM-L and the 50Hz PAL variants. |
687 | if (std & V4L2_STD_525_60) { | 672 | if (std & V4L2_STD_525_60) { |
688 | saa7115_dbg("decoder set standard 60 Hz\n"); | 673 | v4l_dbg(1, client, "decoder set standard 60 Hz\n"); |
689 | saa7115_writeregs(client, saa7115_cfg_60hz_video); | 674 | saa7115_writeregs(client, saa7115_cfg_60hz_video); |
690 | } else { | 675 | } else { |
691 | saa7115_dbg("decoder set standard 50 Hz\n"); | 676 | v4l_dbg(1, client, "decoder set standard 50 Hz\n"); |
692 | saa7115_writeregs(client, saa7115_cfg_50hz_video); | 677 | saa7115_writeregs(client, saa7115_cfg_50hz_video); |
693 | } | 678 | } |
694 | 679 | ||
@@ -717,13 +702,13 @@ static void saa7115_log_status(struct i2c_client *client) | |||
717 | int signalOk; | 702 | int signalOk; |
718 | int vcr; | 703 | int vcr; |
719 | 704 | ||
720 | saa7115_info("Audio frequency: %d Hz\n", state->audclk_freq); | 705 | v4l_info(client, "Audio frequency: %d Hz\n", state->audclk_freq); |
721 | if (client->name[6] == '4') { | 706 | if (client->name[6] == '4') { |
722 | /* status for the saa7114 */ | 707 | /* status for the saa7114 */ |
723 | reg1f = saa7115_read(client, 0x1f); | 708 | reg1f = saa7115_read(client, 0x1f); |
724 | signalOk = (reg1f & 0xc1) == 0x81; | 709 | signalOk = (reg1f & 0xc1) == 0x81; |
725 | saa7115_info("Video signal: %s\n", signalOk ? "ok" : "bad"); | 710 | v4l_info(client, "Video signal: %s\n", signalOk ? "ok" : "bad"); |
726 | saa7115_info("Frequency: %s\n", (reg1f & 0x20) ? "60 Hz" : "50 Hz"); | 711 | v4l_info(client, "Frequency: %s\n", (reg1f & 0x20) ? "60 Hz" : "50 Hz"); |
727 | return; | 712 | return; |
728 | } | 713 | } |
729 | 714 | ||
@@ -735,25 +720,25 @@ static void saa7115_log_status(struct i2c_client *client) | |||
735 | vcr = !(reg1f & 0x10); | 720 | vcr = !(reg1f & 0x10); |
736 | 721 | ||
737 | if (state->input >= 6) { | 722 | if (state->input >= 6) { |
738 | saa7115_info("Input: S-Video %d\n", state->input - 6); | 723 | v4l_info(client, "Input: S-Video %d\n", state->input - 6); |
739 | } else { | 724 | } else { |
740 | saa7115_info("Input: Composite %d\n", state->input); | 725 | v4l_info(client, "Input: Composite %d\n", state->input); |
741 | } | 726 | } |
742 | saa7115_info("Video signal: %s\n", signalOk ? (vcr ? "VCR" : "broadcast/DVD") : "bad"); | 727 | v4l_info(client, "Video signal: %s\n", signalOk ? (vcr ? "VCR" : "broadcast/DVD") : "bad"); |
743 | saa7115_info("Frequency: %s\n", (reg1f & 0x20) ? "60 Hz" : "50 Hz"); | 728 | v4l_info(client, "Frequency: %s\n", (reg1f & 0x20) ? "60 Hz" : "50 Hz"); |
744 | 729 | ||
745 | switch (reg1e & 0x03) { | 730 | switch (reg1e & 0x03) { |
746 | case 1: | 731 | case 1: |
747 | saa7115_info("Detected format: NTSC\n"); | 732 | v4l_info(client, "Detected format: NTSC\n"); |
748 | break; | 733 | break; |
749 | case 2: | 734 | case 2: |
750 | saa7115_info("Detected format: PAL\n"); | 735 | v4l_info(client, "Detected format: PAL\n"); |
751 | break; | 736 | break; |
752 | case 3: | 737 | case 3: |
753 | saa7115_info("Detected format: SECAM\n"); | 738 | v4l_info(client, "Detected format: SECAM\n"); |
754 | break; | 739 | break; |
755 | default: | 740 | default: |
756 | saa7115_info("Detected format: BW/No color\n"); | 741 | v4l_info(client, "Detected format: BW/No color\n"); |
757 | break; | 742 | break; |
758 | } | 743 | } |
759 | } | 744 | } |
@@ -878,7 +863,7 @@ static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt | |||
878 | 863 | ||
879 | pix = &(fmt->fmt.pix); | 864 | pix = &(fmt->fmt.pix); |
880 | 865 | ||
881 | saa7115_dbg("decoder set size\n"); | 866 | v4l_dbg(1, client, "decoder set size\n"); |
882 | 867 | ||
883 | /* FIXME need better bounds checking here */ | 868 | /* FIXME need better bounds checking here */ |
884 | if ((pix->width < 1) || (pix->width > 1440)) | 869 | if ((pix->width < 1) || (pix->width > 1440)) |
@@ -904,7 +889,7 @@ static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt | |||
904 | HPSC = HPSC ? HPSC : 1; | 889 | HPSC = HPSC ? HPSC : 1; |
905 | HFSC = (int)((1024 * 720) / (HPSC * pix->width)); | 890 | HFSC = (int)((1024 * 720) / (HPSC * pix->width)); |
906 | 891 | ||
907 | saa7115_dbg("Hpsc: 0x%05x, Hfsc: 0x%05x\n", HPSC, HFSC); | 892 | v4l_dbg(1, client, "Hpsc: 0x%05x, Hfsc: 0x%05x\n", HPSC, HFSC); |
908 | /* FIXME hardcodes to "Task B" | 893 | /* FIXME hardcodes to "Task B" |
909 | * write H prescaler integer */ | 894 | * write H prescaler integer */ |
910 | saa7115_write(client, 0xd0, (u8) (HPSC & 0x3f)); | 895 | saa7115_write(client, 0xd0, (u8) (HPSC & 0x3f)); |
@@ -918,10 +903,10 @@ static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt | |||
918 | saa7115_write(client, 0xDD, (u8) ((HFSC >> 9) & 0xff)); | 903 | saa7115_write(client, 0xDD, (u8) ((HFSC >> 9) & 0xff)); |
919 | } else { | 904 | } else { |
920 | if (is_50hz) { | 905 | if (is_50hz) { |
921 | saa7115_dbg("Setting full 50hz width\n"); | 906 | v4l_dbg(1, client, "Setting full 50hz width\n"); |
922 | saa7115_writeregs(client, saa7115_cfg_50hz_fullres_x); | 907 | saa7115_writeregs(client, saa7115_cfg_50hz_fullres_x); |
923 | } else { | 908 | } else { |
924 | saa7115_dbg("Setting full 60hz width\n"); | 909 | v4l_dbg(1, client, "Setting full 60hz width\n"); |
925 | saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x); | 910 | saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x); |
926 | } | 911 | } |
927 | } | 912 | } |
@@ -930,7 +915,7 @@ static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt | |||
930 | 915 | ||
931 | if (pix->height != Vsrc) { | 916 | if (pix->height != Vsrc) { |
932 | VSCY = (int)((1024 * Vsrc) / pix->height); | 917 | VSCY = (int)((1024 * Vsrc) / pix->height); |
933 | saa7115_dbg("Vsrc: %d, Vscy: 0x%05x\n", Vsrc, VSCY); | 918 | v4l_dbg(1, client, "Vsrc: %d, Vscy: 0x%05x\n", Vsrc, VSCY); |
934 | 919 | ||
935 | /* Correct Contrast and Luminance */ | 920 | /* Correct Contrast and Luminance */ |
936 | saa7115_write(client, 0xd5, (u8) (64 * 1024 / VSCY)); | 921 | saa7115_write(client, 0xd5, (u8) (64 * 1024 / VSCY)); |
@@ -944,10 +929,10 @@ static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt | |||
944 | saa7115_write(client, 0xe3, (u8) ((VSCY >> 8) & 0xff)); | 929 | saa7115_write(client, 0xe3, (u8) ((VSCY >> 8) & 0xff)); |
945 | } else { | 930 | } else { |
946 | if (is_50hz) { | 931 | if (is_50hz) { |
947 | saa7115_dbg("Setting full 50Hz height\n"); | 932 | v4l_dbg(1, client, "Setting full 50Hz height\n"); |
948 | saa7115_writeregs(client, saa7115_cfg_50hz_fullres_y); | 933 | saa7115_writeregs(client, saa7115_cfg_50hz_fullres_y); |
949 | } else { | 934 | } else { |
950 | saa7115_dbg("Setting full 60hz height\n"); | 935 | v4l_dbg(1, client, "Setting full 60hz height\n"); |
951 | saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y); | 936 | saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y); |
952 | } | 937 | } |
953 | } | 938 | } |
@@ -1052,7 +1037,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar | |||
1052 | break; | 1037 | break; |
1053 | status = saa7115_read(client, 0x1f); | 1038 | status = saa7115_read(client, 0x1f); |
1054 | 1039 | ||
1055 | saa7115_dbg("status: 0x%02x\n", status); | 1040 | v4l_dbg(1, client, "status: 0x%02x\n", status); |
1056 | vt->signal = ((status & (1 << 6)) == 0) ? 0xffff : 0x0; | 1041 | vt->signal = ((status & (1 << 6)) == 0) ? 0xffff : 0x0; |
1057 | break; | 1042 | break; |
1058 | } | 1043 | } |
@@ -1085,7 +1070,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar | |||
1085 | break; | 1070 | break; |
1086 | 1071 | ||
1087 | case VIDIOC_S_INPUT: | 1072 | case VIDIOC_S_INPUT: |
1088 | saa7115_dbg("decoder set input %d\n", *iarg); | 1073 | v4l_dbg(1, client, "decoder set input %d\n", *iarg); |
1089 | /* inputs from 0-9 are available */ | 1074 | /* inputs from 0-9 are available */ |
1090 | if (*iarg < 0 || *iarg > 9) { | 1075 | if (*iarg < 0 || *iarg > 9) { |
1091 | return -EINVAL; | 1076 | return -EINVAL; |
@@ -1093,7 +1078,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar | |||
1093 | 1078 | ||
1094 | if (state->input == *iarg) | 1079 | if (state->input == *iarg) |
1095 | break; | 1080 | break; |
1096 | saa7115_dbg("now setting %s input\n", | 1081 | v4l_dbg(1, client, "now setting %s input\n", |
1097 | *iarg >= 6 ? "S-Video" : "Composite"); | 1082 | *iarg >= 6 ? "S-Video" : "Composite"); |
1098 | state->input = *iarg; | 1083 | state->input = *iarg; |
1099 | 1084 | ||
@@ -1110,7 +1095,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar | |||
1110 | 1095 | ||
1111 | case VIDIOC_STREAMON: | 1096 | case VIDIOC_STREAMON: |
1112 | case VIDIOC_STREAMOFF: | 1097 | case VIDIOC_STREAMOFF: |
1113 | saa7115_dbg("%s output\n", | 1098 | v4l_dbg(1, client, "%s output\n", |
1114 | (cmd == VIDIOC_STREAMON) ? "enable" : "disable"); | 1099 | (cmd == VIDIOC_STREAMON) ? "enable" : "disable"); |
1115 | 1100 | ||
1116 | if (state->enable != (cmd == VIDIOC_STREAMON)) { | 1101 | if (state->enable != (cmd == VIDIOC_STREAMON)) { |
@@ -1124,7 +1109,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar | |||
1124 | break; | 1109 | break; |
1125 | 1110 | ||
1126 | case VIDIOC_INT_RESET: | 1111 | case VIDIOC_INT_RESET: |
1127 | saa7115_dbg("decoder RESET\n"); | 1112 | v4l_dbg(1, client, "decoder RESET\n"); |
1128 | saa7115_writeregs(client, saa7115_cfg_reset_scaler); | 1113 | saa7115_writeregs(client, saa7115_cfg_reset_scaler); |
1129 | break; | 1114 | break; |
1130 | 1115 | ||
@@ -1218,19 +1203,19 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind) | |||
1218 | client->driver = &i2c_driver_saa7115; | 1203 | client->driver = &i2c_driver_saa7115; |
1219 | snprintf(client->name, sizeof(client->name) - 1, "saa7115"); | 1204 | snprintf(client->name, sizeof(client->name) - 1, "saa7115"); |
1220 | 1205 | ||
1221 | saa7115_dbg("detecting saa7115 client on address 0x%x\n", address << 1); | 1206 | v4l_dbg(1, client, "detecting saa7115 client on address 0x%x\n", address << 1); |
1222 | 1207 | ||
1223 | saa7115_write(client, 0, 5); | 1208 | saa7115_write(client, 0, 5); |
1224 | chip_id = saa7115_read(client, 0) & 0x0f; | 1209 | chip_id = saa7115_read(client, 0) & 0x0f; |
1225 | if (chip_id != 4 && chip_id != 5) { | 1210 | if (chip_id != 4 && chip_id != 5) { |
1226 | saa7115_dbg("saa7115 not found\n"); | 1211 | v4l_dbg(1, client, "saa7115 not found\n"); |
1227 | kfree(client); | 1212 | kfree(client); |
1228 | return 0; | 1213 | return 0; |
1229 | } | 1214 | } |
1230 | if (chip_id == 4) { | 1215 | if (chip_id == 4) { |
1231 | snprintf(client->name, sizeof(client->name) - 1, "saa7114"); | 1216 | snprintf(client->name, sizeof(client->name) - 1, "saa7114"); |
1232 | } | 1217 | } |
1233 | saa7115_info("saa711%d found @ 0x%x (%s)\n", chip_id, address << 1, adapter->name); | 1218 | v4l_info(client, "saa711%d found @ 0x%x (%s)\n", chip_id, address << 1, adapter->name); |
1234 | 1219 | ||
1235 | state = kmalloc(sizeof(struct saa7115_state), GFP_KERNEL); | 1220 | state = kmalloc(sizeof(struct saa7115_state), GFP_KERNEL); |
1236 | i2c_set_clientdata(client, state); | 1221 | i2c_set_clientdata(client, state); |
@@ -1250,7 +1235,7 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind) | |||
1250 | state->ident = (chip_id == 4) ? V4L2_IDENT_SAA7114 : V4L2_IDENT_SAA7115; | 1235 | state->ident = (chip_id == 4) ? V4L2_IDENT_SAA7114 : V4L2_IDENT_SAA7115; |
1251 | state->audclk_freq = 48000; | 1236 | state->audclk_freq = 48000; |
1252 | 1237 | ||
1253 | saa7115_dbg("writing init values\n"); | 1238 | v4l_dbg(1, client, "writing init values\n"); |
1254 | 1239 | ||
1255 | /* init to 60hz/48khz */ | 1240 | /* init to 60hz/48khz */ |
1256 | saa7115_writeregs(client, saa7115_init_auto_input); | 1241 | saa7115_writeregs(client, saa7115_init_auto_input); |
@@ -1263,7 +1248,7 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind) | |||
1263 | 1248 | ||
1264 | i2c_attach_client(client); | 1249 | i2c_attach_client(client); |
1265 | 1250 | ||
1266 | saa7115_dbg("status: (1E) 0x%02x, (1F) 0x%02x\n", | 1251 | v4l_dbg(1, client, "status: (1E) 0x%02x, (1F) 0x%02x\n", |
1267 | saa7115_read(client, 0x1e), saa7115_read(client, 0x1f)); | 1252 | saa7115_read(client, 0x1e), saa7115_read(client, 0x1f)); |
1268 | 1253 | ||
1269 | return 0; | 1254 | return 0; |