aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorWolfgang Rohdewald <wolfgang@rohdewald.de>2005-07-07 20:57:59 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-07 21:23:58 -0400
commitce18a223607b0e8cc9a8375abc64281a13ac423c (patch)
tree0c24eea6aae67bb7de1c4b2c2533437f09cc4fd1 /drivers/media/dvb
parenteef5764d6806e29a768a632abce113c15264c5d6 (diff)
[PATCH] dvb: ttpci: more error handling for firmware communication
o propagate more errors back to caller or log them, mainly in av7110.c and av7110_av.c o fix error message in StartHWFilter o do not StopHWFilter for handle 0xffff Signed-off-by: Wolfgang Rohdewald <wolfgang@rohdewald.de> Signed-off-by: Johannes Stezenbach <js@linuxtv.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/ttpci/av7110.c237
-rw-r--r--drivers/media/dvb/ttpci/av7110.h4
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.c210
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.h4
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.h12
5 files changed, 280 insertions, 187 deletions
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 8e33a850e13e..e21deee9a985 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -116,13 +116,18 @@ static int av7110_num = 0;
116 116
117static void init_av7110_av(struct av7110 *av7110) 117static void init_av7110_av(struct av7110 *av7110)
118{ 118{
119 int ret;
119 struct saa7146_dev *dev = av7110->dev; 120 struct saa7146_dev *dev = av7110->dev;
120 121
121 /* set internal volume control to maximum */ 122 /* set internal volume control to maximum */
122 av7110->adac_type = DVB_ADAC_TI; 123 av7110->adac_type = DVB_ADAC_TI;
123 av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right); 124 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
125 if (ret<0)
126 printk("dvb-ttpci:cannot set internal volume to maximum:%d\n",ret);
124 127
125 av7710_set_video_mode(av7110, vidmode); 128 ret = av7710_set_video_mode(av7110, vidmode);
129 if (ret<0)
130 printk("dvb-ttpci:cannot set video mode:%d\n",ret);
126 131
127 /* handle different card types */ 132 /* handle different card types */
128 /* remaining inits according to card and frontend type */ 133 /* remaining inits according to card and frontend type */
@@ -156,8 +161,12 @@ static void init_av7110_av(struct av7110 *av7110)
156 161
157 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) { 162 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) {
158 // switch DVB SCART on 163 // switch DVB SCART on
159 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0); 164 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0);
160 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 1); 165 if (ret<0)
166 printk("dvb-ttpci:cannot switch on SCART(Main):%d\n",ret);
167 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 1);
168 if (ret<0)
169 printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret);
161 if (rgb_on && 170 if (rgb_on &&
162 (av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) { 171 (av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) {
163 saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16 172 saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16
@@ -165,8 +174,12 @@ static void init_av7110_av(struct av7110 *av7110)
165 } 174 }
166 } 175 }
167 176
168 av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right); 177 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
169 av7110_setup_irc_config(av7110, 0); 178 if (ret<0)
179 printk("dvb-ttpci:cannot set volume :%d\n",ret);
180 ret = av7110_setup_irc_config(av7110, 0);
181 if (ret<0)
182 printk("dvb-ttpci:cannot setup irc config :%d\n",ret);
170} 183}
171 184
172static void recover_arm(struct av7110 *av7110) 185static void recover_arm(struct av7110 *av7110)
@@ -258,8 +271,9 @@ static int arm_thread(void *data)
258 * 271 *
259 * If we want to support multiple controls we would have to do much more... 272 * If we want to support multiple controls we would have to do much more...
260 */ 273 */
261void av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config) 274int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config)
262{ 275{
276 int ret = 0;
263 static struct av7110 *last; 277 static struct av7110 *last;
264 278
265 dprintk(4, "%p\n", av7110); 279 dprintk(4, "%p\n", av7110);
@@ -270,9 +284,10 @@ void av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config)
270 last = av7110; 284 last = av7110;
271 285
272 if (av7110) { 286 if (av7110) {
273 av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config); 287 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config);
274 av7110->ir_config = ir_config; 288 av7110->ir_config = ir_config;
275 } 289 }
290 return ret;
276} 291}
277 292
278static void (*irc_handler)(u32); 293static void (*irc_handler)(u32);
@@ -765,13 +780,14 @@ static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
765 pcrpid, vpid, apid, ttpid, subpid); 780 pcrpid, vpid, apid, ttpid, subpid);
766} 781}
767 782
768void ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, 783int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
769 u16 subpid, u16 pcrpid) 784 u16 subpid, u16 pcrpid)
770{ 785{
786 int ret = 0;
771 dprintk(4, "%p\n", av7110); 787 dprintk(4, "%p\n", av7110);
772 788
773 if (down_interruptible(&av7110->pid_mutex)) 789 if (down_interruptible(&av7110->pid_mutex))
774 return; 790 return -ERESTARTSYS;
775 791
776 if (!(vpid & 0x8000)) 792 if (!(vpid & 0x8000))
777 av7110->pids[DMX_PES_VIDEO] = vpid; 793 av7110->pids[DMX_PES_VIDEO] = vpid;
@@ -786,10 +802,11 @@ void ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
786 802
787 if (av7110->fe_synced) { 803 if (av7110->fe_synced) {
788 pcrpid = av7110->pids[DMX_PES_PCR]; 804 pcrpid = av7110->pids[DMX_PES_PCR];
789 SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid); 805 ret = SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid);
790 } 806 }
791 807
792 up(&av7110->pid_mutex); 808 up(&av7110->pid_mutex);
809 return ret;
793} 810}
794 811
795 812
@@ -832,11 +849,13 @@ static int StartHWFilter(struct dvb_demux_filter *dvbdmxfilter)
832 ret = av7110_fw_request(av7110, buf, 20, &handle, 1); 849 ret = av7110_fw_request(av7110, buf, 20, &handle, 1);
833 if (ret != 0 || handle >= 32) { 850 if (ret != 0 || handle >= 32) {
834 printk("dvb-ttpci: %s error buf %04x %04x %04x %04x " 851 printk("dvb-ttpci: %s error buf %04x %04x %04x %04x "
835 "ret %x handle %04x\n", 852 "ret %d handle %04x\n",
836 __FUNCTION__, buf[0], buf[1], buf[2], buf[3], 853 __FUNCTION__, buf[0], buf[1], buf[2], buf[3],
837 ret, handle); 854 ret, handle);
838 dvbdmxfilter->hw_handle = 0xffff; 855 dvbdmxfilter->hw_handle = 0xffff;
839 return -1; 856 if (!ret)
857 ret = -1;
858 return ret;
840 } 859 }
841 860
842 av7110->handle2filter[handle] = dvbdmxfilter; 861 av7110->handle2filter[handle] = dvbdmxfilter;
@@ -859,7 +878,7 @@ static int StopHWFilter(struct dvb_demux_filter *dvbdmxfilter)
859 if (handle >= 32) { 878 if (handle >= 32) {
860 printk("%s tried to stop invalid filter %04x, filter type = %x\n", 879 printk("%s tried to stop invalid filter %04x, filter type = %x\n",
861 __FUNCTION__, handle, dvbdmxfilter->type); 880 __FUNCTION__, handle, dvbdmxfilter->type);
862 return 0; 881 return -EINVAL;
863 } 882 }
864 883
865 av7110->handle2filter[handle] = NULL; 884 av7110->handle2filter[handle] = NULL;
@@ -873,18 +892,20 @@ static int StopHWFilter(struct dvb_demux_filter *dvbdmxfilter)
873 "resp %04x %04x pid %d\n", 892 "resp %04x %04x pid %d\n",
874 __FUNCTION__, buf[0], buf[1], buf[2], ret, 893 __FUNCTION__, buf[0], buf[1], buf[2], ret,
875 answ[0], answ[1], dvbdmxfilter->feed->pid); 894 answ[0], answ[1], dvbdmxfilter->feed->pid);
876 ret = -1; 895 if (!ret)
896 ret = -1;
877 } 897 }
878 return ret; 898 return ret;
879} 899}
880 900
881 901
882static void dvb_feed_start_pid(struct dvb_demux_feed *dvbdmxfeed) 902static int dvb_feed_start_pid(struct dvb_demux_feed *dvbdmxfeed)
883{ 903{
884 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 904 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
885 struct av7110 *av7110 = (struct av7110 *) dvbdmx->priv; 905 struct av7110 *av7110 = (struct av7110 *) dvbdmx->priv;
886 u16 *pid = dvbdmx->pids, npids[5]; 906 u16 *pid = dvbdmx->pids, npids[5];
887 int i; 907 int i;
908 int ret = 0;
888 909
889 dprintk(4, "%p\n", av7110); 910 dprintk(4, "%p\n", av7110);
890 911
@@ -893,36 +914,49 @@ static void dvb_feed_start_pid(struct dvb_demux_feed *dvbdmxfeed)
893 npids[i] = (pid[i]&0x8000) ? 0 : pid[i]; 914 npids[i] = (pid[i]&0x8000) ? 0 : pid[i];
894 if ((i == 2) && npids[i] && (dvbdmxfeed->ts_type & TS_PACKET)) { 915 if ((i == 2) && npids[i] && (dvbdmxfeed->ts_type & TS_PACKET)) {
895 npids[i] = 0; 916 npids[i] = 0;
896 ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]); 917 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
897 StartHWFilter(dvbdmxfeed->filter); 918 if (!ret)
898 return; 919 ret = StartHWFilter(dvbdmxfeed->filter);
920 return ret;
921 }
922 if (dvbdmxfeed->pes_type <= 2 || dvbdmxfeed->pes_type == 4) {
923 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
924 if (ret)
925 return ret;
899 } 926 }
900 if (dvbdmxfeed->pes_type <= 2 || dvbdmxfeed->pes_type == 4)
901 ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
902 927
903 if (dvbdmxfeed->pes_type < 2 && npids[0]) 928 if (dvbdmxfeed->pes_type < 2 && npids[0])
904 if (av7110->fe_synced) 929 if (av7110->fe_synced)
905 av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0); 930 {
931 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
932 if (ret)
933 return ret;
934 }
906 935
907 if ((dvbdmxfeed->ts_type & TS_PACKET)) { 936 if ((dvbdmxfeed->ts_type & TS_PACKET)) {
908 if (dvbdmxfeed->pes_type == 0 && !(dvbdmx->pids[0] & 0x8000)) 937 if (dvbdmxfeed->pes_type == 0 && !(dvbdmx->pids[0] & 0x8000))
909 av7110_av_start_record(av7110, RP_AUDIO, dvbdmxfeed); 938 ret = av7110_av_start_record(av7110, RP_AUDIO, dvbdmxfeed);
910 if (dvbdmxfeed->pes_type == 1 && !(dvbdmx->pids[1] & 0x8000)) 939 if (dvbdmxfeed->pes_type == 1 && !(dvbdmx->pids[1] & 0x8000))
911 av7110_av_start_record(av7110, RP_VIDEO, dvbdmxfeed); 940 ret = av7110_av_start_record(av7110, RP_VIDEO, dvbdmxfeed);
912 } 941 }
942 return ret;
913} 943}
914 944
915static void dvb_feed_stop_pid(struct dvb_demux_feed *dvbdmxfeed) 945static int dvb_feed_stop_pid(struct dvb_demux_feed *dvbdmxfeed)
916{ 946{
917 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 947 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
918 struct av7110 *av7110 = (struct av7110 *) dvbdmx->priv; 948 struct av7110 *av7110 = (struct av7110 *) dvbdmx->priv;
919 u16 *pid = dvbdmx->pids, npids[5]; 949 u16 *pid = dvbdmx->pids, npids[5];
920 int i; 950 int i;
921 951
952 int ret = 0;
953
922 dprintk(4, "%p\n", av7110); 954 dprintk(4, "%p\n", av7110);
923 955
924 if (dvbdmxfeed->pes_type <= 1) { 956 if (dvbdmxfeed->pes_type <= 1) {
925 av7110_av_stop(av7110, dvbdmxfeed->pes_type ? RP_VIDEO : RP_AUDIO); 957 ret = av7110_av_stop(av7110, dvbdmxfeed->pes_type ? RP_VIDEO : RP_AUDIO);
958 if (ret)
959 return ret;
926 if (!av7110->rec_mode) 960 if (!av7110->rec_mode)
927 dvbdmx->recording = 0; 961 dvbdmx->recording = 0;
928 if (!av7110->playing) 962 if (!av7110->playing)
@@ -933,24 +967,27 @@ static void dvb_feed_stop_pid(struct dvb_demux_feed *dvbdmxfeed)
933 switch (i) { 967 switch (i) {
934 case 2: //teletext 968 case 2: //teletext
935 if (dvbdmxfeed->ts_type & TS_PACKET) 969 if (dvbdmxfeed->ts_type & TS_PACKET)
936 StopHWFilter(dvbdmxfeed->filter); 970 ret = StopHWFilter(dvbdmxfeed->filter);
937 npids[2] = 0; 971 npids[2] = 0;
938 break; 972 break;
939 case 0: 973 case 0:
940 case 1: 974 case 1:
941 case 4: 975 case 4:
942 if (!pids_off) 976 if (!pids_off)
943 return; 977 return 0;
944 npids[i] = (pid[i]&0x8000) ? 0 : pid[i]; 978 npids[i] = (pid[i]&0x8000) ? 0 : pid[i];
945 break; 979 break;
946 } 980 }
947 ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]); 981 if (!ret)
982 ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
983 return ret;
948} 984}
949 985
950static int av7110_start_feed(struct dvb_demux_feed *feed) 986static int av7110_start_feed(struct dvb_demux_feed *feed)
951{ 987{
952 struct dvb_demux *demux = feed->demux; 988 struct dvb_demux *demux = feed->demux;
953 struct av7110 *av7110 = demux->priv; 989 struct av7110 *av7110 = demux->priv;
990 int ret = 0;
954 991
955 dprintk(4, "%p\n", av7110); 992 dprintk(4, "%p\n", av7110);
956 993
@@ -971,21 +1008,22 @@ static int av7110_start_feed(struct dvb_demux_feed *feed)
971 !(demux->pids[1] & 0x8000)) { 1008 !(demux->pids[1] & 0x8000)) {
972 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout); 1009 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
973 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout); 1010 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
974 av7110_av_start_play(av7110,RP_AV); 1011 ret = av7110_av_start_play(av7110,RP_AV);
975 demux->playing = 1; 1012 if (!ret)
1013 demux->playing = 1;
976 } 1014 }
977 break; 1015 break;
978 default: 1016 default:
979 dvb_feed_start_pid(feed); 1017 ret = dvb_feed_start_pid(feed);
980 break; 1018 break;
981 } 1019 }
982 } else if ((feed->ts_type & TS_PACKET) && 1020 } else if ((feed->ts_type & TS_PACKET) &&
983 (demux->dmx.frontend->source != DMX_MEMORY_FE)) { 1021 (demux->dmx.frontend->source != DMX_MEMORY_FE)) {
984 StartHWFilter(feed->filter); 1022 ret = StartHWFilter(feed->filter);
985 } 1023 }
986 } 1024 }
987 1025
988 if (feed->type == DMX_TYPE_SEC) { 1026 else if (feed->type == DMX_TYPE_SEC) {
989 int i; 1027 int i;
990 1028
991 for (i = 0; i < demux->filternum; i++) { 1029 for (i = 0; i < demux->filternum; i++) {
@@ -996,12 +1034,15 @@ static int av7110_start_feed(struct dvb_demux_feed *feed)
996 if (demux->filter[i].filter.parent != &feed->feed.sec) 1034 if (demux->filter[i].filter.parent != &feed->feed.sec)
997 continue; 1035 continue;
998 demux->filter[i].state = DMX_STATE_GO; 1036 demux->filter[i].state = DMX_STATE_GO;
999 if (demux->dmx.frontend->source != DMX_MEMORY_FE) 1037 if (demux->dmx.frontend->source != DMX_MEMORY_FE) {
1000 StartHWFilter(&demux->filter[i]); 1038 ret = StartHWFilter(&demux->filter[i]);
1039 if (ret)
1040 break;
1041 }
1001 } 1042 }
1002 } 1043 }
1003 1044
1004 return 0; 1045 return ret;
1005} 1046}
1006 1047
1007 1048
@@ -1010,6 +1051,7 @@ static int av7110_stop_feed(struct dvb_demux_feed *feed)
1010 struct dvb_demux *demux = feed->demux; 1051 struct dvb_demux *demux = feed->demux;
1011 struct av7110 *av7110 = demux->priv; 1052 struct av7110 *av7110 = demux->priv;
1012 1053
1054 int ret = 0;
1013 dprintk(4, "%p\n", av7110); 1055 dprintk(4, "%p\n", av7110);
1014 1056
1015 if (feed->type == DMX_TYPE_TS) { 1057 if (feed->type == DMX_TYPE_TS) {
@@ -1022,26 +1064,29 @@ static int av7110_stop_feed(struct dvb_demux_feed *feed)
1022 } 1064 }
1023 if (feed->ts_type & TS_DECODER && 1065 if (feed->ts_type & TS_DECODER &&
1024 feed->pes_type < DMX_TS_PES_OTHER) { 1066 feed->pes_type < DMX_TS_PES_OTHER) {
1025 dvb_feed_stop_pid(feed); 1067 ret = dvb_feed_stop_pid(feed);
1026 } else 1068 } else
1027 if ((feed->ts_type & TS_PACKET) && 1069 if ((feed->ts_type & TS_PACKET) &&
1028 (demux->dmx.frontend->source != DMX_MEMORY_FE)) 1070 (demux->dmx.frontend->source != DMX_MEMORY_FE))
1029 StopHWFilter(feed->filter); 1071 ret = StopHWFilter(feed->filter);
1030 } 1072 }
1031 1073
1032 if (feed->type == DMX_TYPE_SEC) { 1074 if (!ret && feed->type == DMX_TYPE_SEC) {
1033 int i; 1075 int i;
1034 1076
1035 for (i = 0; i<demux->filternum; i++) 1077 for (i = 0; i<demux->filternum; i++)
1036 if (demux->filter[i].state == DMX_STATE_GO && 1078 if (demux->filter[i].state == DMX_STATE_GO &&
1037 demux->filter[i].filter.parent == &feed->feed.sec) { 1079 demux->filter[i].filter.parent == &feed->feed.sec) {
1038 demux->filter[i].state = DMX_STATE_READY; 1080 demux->filter[i].state = DMX_STATE_READY;
1039 if (demux->dmx.frontend->source != DMX_MEMORY_FE) 1081 if (demux->dmx.frontend->source != DMX_MEMORY_FE) {
1040 StopHWFilter(&demux->filter[i]); 1082 ret = StopHWFilter(&demux->filter[i]);
1083 if (ret)
1084 break;
1085 }
1041 } 1086 }
1042 } 1087 }
1043 1088
1044 return 0; 1089 return ret;
1045} 1090}
1046 1091
1047 1092
@@ -1093,7 +1138,7 @@ static int dvb_get_stc(struct dmx_demux *demux, unsigned int num,
1093 ret = av7110_fw_request(av7110, &tag, 0, fwstc, 4); 1138 ret = av7110_fw_request(av7110, &tag, 0, fwstc, 4);
1094 if (ret) { 1139 if (ret) {
1095 printk(KERN_ERR "%s: av7110_fw_request error\n", __FUNCTION__); 1140 printk(KERN_ERR "%s: av7110_fw_request error\n", __FUNCTION__);
1096 return -EIO; 1141 return ret;
1097 } 1142 }
1098 dprintk(2, "fwstc = %04hx %04hx %04hx %04hx\n", 1143 dprintk(2, "fwstc = %04hx %04hx %04hx %04hx\n",
1099 fwstc[0], fwstc[1], fwstc[2], fwstc[3]); 1144 fwstc[0], fwstc[1], fwstc[2], fwstc[3]);
@@ -1119,18 +1164,14 @@ static int av7110_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
1119 1164
1120 switch (tone) { 1165 switch (tone) {
1121 case SEC_TONE_ON: 1166 case SEC_TONE_ON:
1122 Set22K(av7110, 1); 1167 return Set22K(av7110, 1);
1123 break;
1124 1168
1125 case SEC_TONE_OFF: 1169 case SEC_TONE_OFF:
1126 Set22K(av7110, 0); 1170 return Set22K(av7110, 0);
1127 break;
1128 1171
1129 default: 1172 default:
1130 return -EINVAL; 1173 return -EINVAL;
1131 } 1174 }
1132
1133 return 0;
1134} 1175}
1135 1176
1136static int av7110_diseqc_send_master_cmd(struct dvb_frontend* fe, 1177static int av7110_diseqc_send_master_cmd(struct dvb_frontend* fe,
@@ -1138,9 +1179,7 @@ static int av7110_diseqc_send_master_cmd(struct dvb_frontend* fe,
1138{ 1179{
1139 struct av7110* av7110 = fe->dvb->priv; 1180 struct av7110* av7110 = fe->dvb->priv;
1140 1181
1141 av7110_diseqc_send(av7110, cmd->msg_len, cmd->msg, -1); 1182 return av7110_diseqc_send(av7110, cmd->msg_len, cmd->msg, -1);
1142
1143 return 0;
1144} 1183}
1145 1184
1146static int av7110_diseqc_send_burst(struct dvb_frontend* fe, 1185static int av7110_diseqc_send_burst(struct dvb_frontend* fe,
@@ -1148,9 +1187,7 @@ static int av7110_diseqc_send_burst(struct dvb_frontend* fe,
1148{ 1187{
1149 struct av7110* av7110 = fe->dvb->priv; 1188 struct av7110* av7110 = fe->dvb->priv;
1150 1189
1151 av7110_diseqc_send(av7110, 0, NULL, minicmd); 1190 return av7110_diseqc_send(av7110, 0, NULL, minicmd);
1152
1153 return 0;
1154} 1191}
1155 1192
1156/* simplified code from budget-core.c */ 1193/* simplified code from budget-core.c */
@@ -1992,76 +2029,84 @@ static struct l64781_config grundig_29504_401_config = {
1992 2029
1993 2030
1994 2031
1995static void av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status) 2032static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
1996{ 2033{
2034 int ret = 0;
1997 int synced = (status & FE_HAS_LOCK) ? 1 : 0; 2035 int synced = (status & FE_HAS_LOCK) ? 1 : 0;
1998 2036
1999 av7110->fe_status = status; 2037 av7110->fe_status = status;
2000 2038
2001 if (av7110->fe_synced == synced) 2039 if (av7110->fe_synced == synced)
2002 return; 2040 return 0;
2003 2041
2004 av7110->fe_synced = synced; 2042 av7110->fe_synced = synced;
2005 2043
2006 if (av7110->playing) 2044 if (av7110->playing)
2007 return; 2045 return 0;
2008 2046
2009 if (down_interruptible(&av7110->pid_mutex)) 2047 if (down_interruptible(&av7110->pid_mutex))
2010 return; 2048 return -ERESTARTSYS;
2011 2049
2012 if (av7110->fe_synced) { 2050 if (av7110->fe_synced) {
2013 SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO], 2051 ret = SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO],
2014 av7110->pids[DMX_PES_AUDIO], 2052 av7110->pids[DMX_PES_AUDIO],
2015 av7110->pids[DMX_PES_TELETEXT], 0, 2053 av7110->pids[DMX_PES_TELETEXT], 0,
2016 av7110->pids[DMX_PES_PCR]); 2054 av7110->pids[DMX_PES_PCR]);
2017 av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0); 2055 if (!ret)
2056 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
2018 } else { 2057 } else {
2019 SetPIDs(av7110, 0, 0, 0, 0, 0); 2058 ret = SetPIDs(av7110, 0, 0, 0, 0, 0);
2020 av7110_fw_cmd(av7110, COMTYPE_PID_FILTER, FlushTSQueue, 0); 2059 if (!ret) {
2021 av7110_wait_msgstate(av7110, GPMQBusy); 2060 ret = av7110_fw_cmd(av7110, COMTYPE_PID_FILTER, FlushTSQueue, 0);
2061 if (!ret)
2062 ret = av7110_wait_msgstate(av7110, GPMQBusy);
2063 }
2022 } 2064 }
2023 2065
2024 up(&av7110->pid_mutex); 2066 up(&av7110->pid_mutex);
2067 return ret;
2025} 2068}
2026 2069
2027static int av7110_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 2070static int av7110_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
2028{ 2071{
2029 struct av7110* av7110 = fe->dvb->priv; 2072 struct av7110* av7110 = fe->dvb->priv;
2030 av7110_fe_lock_fix(av7110, 0); 2073
2031 return av7110->fe_set_frontend(fe, params); 2074 int ret = av7110_fe_lock_fix(av7110, 0);
2075 if (!ret)
2076 ret = av7110->fe_set_frontend(fe, params);
2077 return ret;
2032} 2078}
2033 2079
2034static int av7110_fe_init(struct dvb_frontend* fe) 2080static int av7110_fe_init(struct dvb_frontend* fe)
2035{ 2081{
2036 struct av7110* av7110 = fe->dvb->priv; 2082 struct av7110* av7110 = fe->dvb->priv;
2037 2083
2038 av7110_fe_lock_fix(av7110, 0); 2084 int ret = av7110_fe_lock_fix(av7110, 0);
2039 return av7110->fe_init(fe); 2085 if (!ret)
2086 ret = av7110->fe_init(fe);
2087 return ret;
2040} 2088}
2041 2089
2042static int av7110_fe_read_status(struct dvb_frontend* fe, fe_status_t* status) 2090static int av7110_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
2043{ 2091{
2044 struct av7110* av7110 = fe->dvb->priv; 2092 struct av7110* av7110 = fe->dvb->priv;
2045 int ret;
2046 2093
2047 /* call the real implementation */ 2094 /* call the real implementation */
2048 ret = av7110->fe_read_status(fe, status); 2095 int ret = av7110->fe_read_status(fe, status);
2049 if (ret) 2096 if (!ret)
2050 return ret; 2097 if (((*status ^ av7110->fe_status) & FE_HAS_LOCK) && (*status & FE_HAS_LOCK))
2051 2098 ret = av7110_fe_lock_fix(av7110, *status);
2052 if (((*status ^ av7110->fe_status) & FE_HAS_LOCK) && (*status & FE_HAS_LOCK)) { 2099 return ret;
2053 av7110_fe_lock_fix(av7110, *status);
2054 }
2055
2056 return 0;
2057} 2100}
2058 2101
2059static int av7110_fe_diseqc_reset_overload(struct dvb_frontend* fe) 2102static int av7110_fe_diseqc_reset_overload(struct dvb_frontend* fe)
2060{ 2103{
2061 struct av7110* av7110 = fe->dvb->priv; 2104 struct av7110* av7110 = fe->dvb->priv;
2062 2105
2063 av7110_fe_lock_fix(av7110, 0); 2106 int ret = av7110_fe_lock_fix(av7110, 0);
2064 return av7110->fe_diseqc_reset_overload(fe); 2107 if (!ret)
2108 ret = av7110->fe_diseqc_reset_overload(fe);
2109 return ret;
2065} 2110}
2066 2111
2067static int av7110_fe_diseqc_send_master_cmd(struct dvb_frontend* fe, 2112static int av7110_fe_diseqc_send_master_cmd(struct dvb_frontend* fe,
@@ -2069,40 +2114,50 @@ static int av7110_fe_diseqc_send_master_cmd(struct dvb_frontend* fe,
2069{ 2114{
2070 struct av7110* av7110 = fe->dvb->priv; 2115 struct av7110* av7110 = fe->dvb->priv;
2071 2116
2072 av7110_fe_lock_fix(av7110, 0); 2117 int ret = av7110_fe_lock_fix(av7110, 0);
2073 return av7110->fe_diseqc_send_master_cmd(fe, cmd); 2118 if (!ret)
2119 ret = av7110->fe_diseqc_send_master_cmd(fe, cmd);
2120 return ret;
2074} 2121}
2075 2122
2076static int av7110_fe_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd) 2123static int av7110_fe_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
2077{ 2124{
2078 struct av7110* av7110 = fe->dvb->priv; 2125 struct av7110* av7110 = fe->dvb->priv;
2079 2126
2080 av7110_fe_lock_fix(av7110, 0); 2127 int ret = av7110_fe_lock_fix(av7110, 0);
2081 return av7110->fe_diseqc_send_burst(fe, minicmd); 2128 if (!ret)
2129 ret = av7110->fe_diseqc_send_burst(fe, minicmd);
2130 return ret;
2082} 2131}
2083 2132
2084static int av7110_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 2133static int av7110_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
2085{ 2134{
2086 struct av7110* av7110 = fe->dvb->priv; 2135 struct av7110* av7110 = fe->dvb->priv;
2087 2136
2088 av7110_fe_lock_fix(av7110, 0); 2137 int ret = av7110_fe_lock_fix(av7110, 0);
2089 return av7110->fe_set_tone(fe, tone); 2138 if (!ret)
2139 ret = av7110->fe_set_tone(fe, tone);
2140 return ret;
2090} 2141}
2091 2142
2092static int av7110_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 2143static int av7110_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
2093{ 2144{
2094 struct av7110* av7110 = fe->dvb->priv; 2145 struct av7110* av7110 = fe->dvb->priv;
2095 2146
2096 av7110_fe_lock_fix(av7110, 0); 2147 int ret = av7110_fe_lock_fix(av7110, 0);
2097 return av7110->fe_set_voltage(fe, voltage); 2148 if (!ret)
2149 ret = av7110->fe_set_voltage(fe, voltage);
2150 return ret;
2098} 2151}
2099 2152
2100static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, unsigned int cmd) 2153static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, unsigned int cmd)
2101{ 2154{
2102 struct av7110* av7110 = fe->dvb->priv; 2155 struct av7110* av7110 = fe->dvb->priv;
2103 2156
2104 av7110_fe_lock_fix(av7110, 0); 2157 int ret = av7110_fe_lock_fix(av7110, 0);
2105 return av7110->fe_dishnetwork_send_legacy_command(fe, cmd); 2158 if (!ret)
2159 ret = av7110->fe_dishnetwork_send_legacy_command(fe, cmd);
2160 return ret;
2106} 2161}
2107 2162
2108static u8 read_pwm(struct av7110* av7110) 2163static u8 read_pwm(struct av7110* av7110)
diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h
index e54222d9b3f9..508b7739c609 100644
--- a/drivers/media/dvb/ttpci/av7110.h
+++ b/drivers/media/dvb/ttpci/av7110.h
@@ -254,12 +254,12 @@ struct av7110 {
254}; 254};
255 255
256 256
257extern void ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, 257extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
258 u16 subpid, u16 pcrpid); 258 u16 subpid, u16 pcrpid);
259 259
260extern void av7110_register_irc_handler(void (*func)(u32)); 260extern void av7110_register_irc_handler(void (*func)(u32));
261extern void av7110_unregister_irc_handler(void (*func)(u32)); 261extern void av7110_unregister_irc_handler(void (*func)(u32));
262extern void av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config); 262extern int av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config);
263 263
264extern int av7110_ir_init (void); 264extern int av7110_ir_init (void);
265extern void av7110_ir_exit (void); 265extern void av7110_ir_exit (void);
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index 13c506ea0bbd..bbfad6def474 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -121,6 +121,7 @@ static int dvb_filter_pes2ts_cb(void *priv, unsigned char *data)
121int av7110_av_start_record(struct av7110 *av7110, int av, 121int av7110_av_start_record(struct av7110 *av7110, int av,
122 struct dvb_demux_feed *dvbdmxfeed) 122 struct dvb_demux_feed *dvbdmxfeed)
123{ 123{
124 int ret = 0;
124 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 125 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
125 126
126 dprintk(2, "av7110:%p, , dvb_demux_feed:%p\n", av7110, dvbdmxfeed); 127 dprintk(2, "av7110:%p, , dvb_demux_feed:%p\n", av7110, dvbdmxfeed);
@@ -137,7 +138,7 @@ int av7110_av_start_record(struct av7110 *av7110, int av,
137 dvbdmx->pesfilter[0]->pid, 138 dvbdmx->pesfilter[0]->pid,
138 dvb_filter_pes2ts_cb, 139 dvb_filter_pes2ts_cb,
139 (void *) dvbdmx->pesfilter[0]); 140 (void *) dvbdmx->pesfilter[0]);
140 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AudioPES, 0); 141 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AudioPES, 0);
141 break; 142 break;
142 143
143 case RP_VIDEO: 144 case RP_VIDEO:
@@ -145,7 +146,7 @@ int av7110_av_start_record(struct av7110 *av7110, int av,
145 dvbdmx->pesfilter[1]->pid, 146 dvbdmx->pesfilter[1]->pid,
146 dvb_filter_pes2ts_cb, 147 dvb_filter_pes2ts_cb,
147 (void *) dvbdmx->pesfilter[1]); 148 (void *) dvbdmx->pesfilter[1]);
148 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, VideoPES, 0); 149 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, VideoPES, 0);
149 break; 150 break;
150 151
151 case RP_AV: 152 case RP_AV:
@@ -157,14 +158,15 @@ int av7110_av_start_record(struct av7110 *av7110, int av,
157 dvbdmx->pesfilter[1]->pid, 158 dvbdmx->pesfilter[1]->pid,
158 dvb_filter_pes2ts_cb, 159 dvb_filter_pes2ts_cb,
159 (void *) dvbdmx->pesfilter[1]); 160 (void *) dvbdmx->pesfilter[1]);
160 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AV_PES, 0); 161 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AV_PES, 0);
161 break; 162 break;
162 } 163 }
163 return 0; 164 return ret;
164} 165}
165 166
166int av7110_av_start_play(struct av7110 *av7110, int av) 167int av7110_av_start_play(struct av7110 *av7110, int av)
167{ 168{
169 int ret = 0;
168 dprintk(2, "av7110:%p, \n", av7110); 170 dprintk(2, "av7110:%p, \n", av7110);
169 171
170 if (av7110->rec_mode) 172 if (av7110->rec_mode)
@@ -182,54 +184,57 @@ int av7110_av_start_play(struct av7110 *av7110, int av)
182 av7110->playing |= av; 184 av7110->playing |= av;
183 switch (av7110->playing) { 185 switch (av7110->playing) {
184 case RP_AUDIO: 186 case RP_AUDIO:
185 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AudioPES, 0); 187 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AudioPES, 0);
186 break; 188 break;
187 case RP_VIDEO: 189 case RP_VIDEO:
188 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, VideoPES, 0); 190 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, VideoPES, 0);
189 av7110->sinfo = 0; 191 av7110->sinfo = 0;
190 break; 192 break;
191 case RP_AV: 193 case RP_AV:
192 av7110->sinfo = 0; 194 av7110->sinfo = 0;
193 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AV_PES, 0); 195 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AV_PES, 0);
194 break; 196 break;
195 } 197 }
196 return av7110->playing; 198 if (!ret)
199 ret = av7110->playing;
200 return ret;
197} 201}
198 202
199void av7110_av_stop(struct av7110 *av7110, int av) 203int av7110_av_stop(struct av7110 *av7110, int av)
200{ 204{
205 int ret = 0;
201 dprintk(2, "av7110:%p, \n", av7110); 206 dprintk(2, "av7110:%p, \n", av7110);
202 207
203 if (!(av7110->playing & av) && !(av7110->rec_mode & av)) 208 if (!(av7110->playing & av) && !(av7110->rec_mode & av))
204 return; 209 return 0;
205
206 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0); 210 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0);
207 if (av7110->playing) { 211 if (av7110->playing) {
208 av7110->playing &= ~av; 212 av7110->playing &= ~av;
209 switch (av7110->playing) { 213 switch (av7110->playing) {
210 case RP_AUDIO: 214 case RP_AUDIO:
211 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AudioPES, 0); 215 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AudioPES, 0);
212 break; 216 break;
213 case RP_VIDEO: 217 case RP_VIDEO:
214 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, VideoPES, 0); 218 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, VideoPES, 0);
215 break; 219 break;
216 case RP_NONE: 220 case RP_NONE:
217 av7110_set_vidmode(av7110, av7110->vidmode); 221 ret = av7110_set_vidmode(av7110, av7110->vidmode);
218 break; 222 break;
219 } 223 }
220 } else { 224 } else {
221 av7110->rec_mode &= ~av; 225 av7110->rec_mode &= ~av;
222 switch (av7110->rec_mode) { 226 switch (av7110->rec_mode) {
223 case RP_AUDIO: 227 case RP_AUDIO:
224 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AudioPES, 0); 228 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AudioPES, 0);
225 break; 229 break;
226 case RP_VIDEO: 230 case RP_VIDEO:
227 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, VideoPES, 0); 231 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, VideoPES, 0);
228 break; 232 break;
229 case RP_NONE: 233 case RP_NONE:
230 break; 234 break;
231 } 235 }
232 } 236 }
237 return ret;
233} 238}
234 239
235 240
@@ -317,19 +322,22 @@ int av7110_set_volume(struct av7110 *av7110, int volleft, int volright)
317 return 0; 322 return 0;
318} 323}
319 324
320void av7110_set_vidmode(struct av7110 *av7110, int mode) 325int av7110_set_vidmode(struct av7110 *av7110, int mode)
321{ 326{
327 int ret;
322 dprintk(2, "av7110:%p, \n", av7110); 328 dprintk(2, "av7110:%p, \n", av7110);
323 329
324 av7110_fw_cmd(av7110, COMTYPE_ENCODER, LoadVidCode, 1, mode); 330 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, LoadVidCode, 1, mode);
325 331
326 if (!av7110->playing) { 332 if (!ret && !av7110->playing) {
327 ChangePIDs(av7110, av7110->pids[DMX_PES_VIDEO], 333 ret = ChangePIDs(av7110, av7110->pids[DMX_PES_VIDEO],
328 av7110->pids[DMX_PES_AUDIO], 334 av7110->pids[DMX_PES_AUDIO],
329 av7110->pids[DMX_PES_TELETEXT], 335 av7110->pids[DMX_PES_TELETEXT],
330 0, av7110->pids[DMX_PES_PCR]); 336 0, av7110->pids[DMX_PES_PCR]);
331 av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0); 337 if (!ret)
338 ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
332 } 339 }
340 return ret;
333} 341}
334 342
335 343
@@ -340,17 +348,18 @@ static int sw2mode[16] = {
340 VIDEO_MODE_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL, 348 VIDEO_MODE_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL,
341}; 349};
342 350
343static void get_video_format(struct av7110 *av7110, u8 *buf, int count) 351static int get_video_format(struct av7110 *av7110, u8 *buf, int count)
344{ 352{
345 int i; 353 int i;
346 int hsize, vsize; 354 int hsize, vsize;
347 int sw; 355 int sw;
348 u8 *p; 356 u8 *p;
357 int ret = 0;
349 358
350 dprintk(2, "av7110:%p, \n", av7110); 359 dprintk(2, "av7110:%p, \n", av7110);
351 360
352 if (av7110->sinfo) 361 if (av7110->sinfo)
353 return; 362 return 0;
354 for (i = 7; i < count - 10; i++) { 363 for (i = 7; i < count - 10; i++) {
355 p = buf + i; 364 p = buf + i;
356 if (p[0] || p[1] || p[2] != 0x01 || p[3] != 0xb3) 365 if (p[0] || p[1] || p[2] != 0x01 || p[3] != 0xb3)
@@ -359,11 +368,14 @@ static void get_video_format(struct av7110 *av7110, u8 *buf, int count)
359 hsize = ((p[1] &0xF0) >> 4) | (p[0] << 4); 368 hsize = ((p[1] &0xF0) >> 4) | (p[0] << 4);
360 vsize = ((p[1] &0x0F) << 8) | (p[2]); 369 vsize = ((p[1] &0x0F) << 8) | (p[2]);
361 sw = (p[3] & 0x0F); 370 sw = (p[3] & 0x0F);
362 av7110_set_vidmode(av7110, sw2mode[sw]); 371 ret = av7110_set_vidmode(av7110, sw2mode[sw]);
363 dprintk(2, "playback %dx%d fr=%d\n", hsize, vsize, sw); 372 if (!ret) {
364 av7110->sinfo = 1; 373 dprintk(2, "playback %dx%d fr=%d\n", hsize, vsize, sw);
374 av7110->sinfo = 1;
375 }
365 break; 376 break;
366 } 377 }
378 return ret;
367} 379}
368 380
369 381
@@ -974,7 +986,7 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
974 unsigned long arg = (unsigned long) parg; 986 unsigned long arg = (unsigned long) parg;
975 int ret = 0; 987 int ret = 0;
976 988
977 dprintk(2, "av7110:%p, \n", av7110); 989 dprintk(1, "av7110:%p, cmd=%04x\n", av7110,cmd);
978 990
979 if ((file->f_flags & O_ACCMODE) == O_RDONLY) { 991 if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
980 if ( cmd != VIDEO_GET_STATUS && cmd != VIDEO_GET_EVENT && 992 if ( cmd != VIDEO_GET_STATUS && cmd != VIDEO_GET_EVENT &&
@@ -987,49 +999,57 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
987 case VIDEO_STOP: 999 case VIDEO_STOP:
988 av7110->videostate.play_state = VIDEO_STOPPED; 1000 av7110->videostate.play_state = VIDEO_STOPPED;
989 if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY) 1001 if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY)
990 av7110_av_stop(av7110, RP_VIDEO); 1002 ret = av7110_av_stop(av7110, RP_VIDEO);
991 else 1003 else
992 vidcom(av7110, VIDEO_CMD_STOP, 1004 ret = vidcom(av7110, VIDEO_CMD_STOP,
993 av7110->videostate.video_blank ? 0 : 1); 1005 av7110->videostate.video_blank ? 0 : 1);
994 av7110->trickmode = TRICK_NONE; 1006 if (!ret)
1007 av7110->trickmode = TRICK_NONE;
995 break; 1008 break;
996 1009
997 case VIDEO_PLAY: 1010 case VIDEO_PLAY:
998 av7110->trickmode = TRICK_NONE; 1011 av7110->trickmode = TRICK_NONE;
999 if (av7110->videostate.play_state == VIDEO_FREEZED) { 1012 if (av7110->videostate.play_state == VIDEO_FREEZED) {
1000 av7110->videostate.play_state = VIDEO_PLAYING; 1013 av7110->videostate.play_state = VIDEO_PLAYING;
1001 vidcom(av7110, VIDEO_CMD_PLAY, 0); 1014 ret = vidcom(av7110, VIDEO_CMD_PLAY, 0);
1015 if (ret)
1016 break;
1002 } 1017 }
1003 1018
1004 if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY) { 1019 if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY) {
1005 if (av7110->playing == RP_AV) { 1020 if (av7110->playing == RP_AV) {
1006 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0); 1021 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0);
1022 if (ret)
1023 break;
1007 av7110->playing &= ~RP_VIDEO; 1024 av7110->playing &= ~RP_VIDEO;
1008 } 1025 }
1009 av7110_av_start_play(av7110, RP_VIDEO); 1026 ret = av7110_av_start_play(av7110, RP_VIDEO);
1010 vidcom(av7110, VIDEO_CMD_PLAY, 0);
1011 } else {
1012 //av7110_av_stop(av7110, RP_VIDEO);
1013 vidcom(av7110, VIDEO_CMD_PLAY, 0);
1014 } 1027 }
1015 av7110->videostate.play_state = VIDEO_PLAYING; 1028 if (!ret)
1029 ret = vidcom(av7110, VIDEO_CMD_PLAY, 0);
1030 if (!ret)
1031 av7110->videostate.play_state = VIDEO_PLAYING;
1016 break; 1032 break;
1017 1033
1018 case VIDEO_FREEZE: 1034 case VIDEO_FREEZE:
1019 av7110->videostate.play_state = VIDEO_FREEZED; 1035 av7110->videostate.play_state = VIDEO_FREEZED;
1020 if (av7110->playing & RP_VIDEO) 1036 if (av7110->playing & RP_VIDEO)
1021 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Pause, 0); 1037 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Pause, 0);
1022 else 1038 else
1023 vidcom(av7110, VIDEO_CMD_FREEZE, 1); 1039 ret = vidcom(av7110, VIDEO_CMD_FREEZE, 1);
1024 av7110->trickmode = TRICK_FREEZE; 1040 if (!ret)
1041 av7110->trickmode = TRICK_FREEZE;
1025 break; 1042 break;
1026 1043
1027 case VIDEO_CONTINUE: 1044 case VIDEO_CONTINUE:
1028 if (av7110->playing & RP_VIDEO) 1045 if (av7110->playing & RP_VIDEO)
1029 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Continue, 0); 1046 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Continue, 0);
1030 vidcom(av7110, VIDEO_CMD_PLAY, 0); 1047 if (!ret)
1031 av7110->videostate.play_state = VIDEO_PLAYING; 1048 ret = vidcom(av7110, VIDEO_CMD_PLAY, 0);
1032 av7110->trickmode = TRICK_NONE; 1049 if (!ret) {
1050 av7110->videostate.play_state = VIDEO_PLAYING;
1051 av7110->trickmode = TRICK_NONE;
1052 }
1033 break; 1053 break;
1034 1054
1035 case VIDEO_SELECT_SOURCE: 1055 case VIDEO_SELECT_SOURCE:
@@ -1045,7 +1065,7 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
1045 break; 1065 break;
1046 1066
1047 case VIDEO_GET_EVENT: 1067 case VIDEO_GET_EVENT:
1048 ret=dvb_video_get_event(av7110, parg, file->f_flags); 1068 ret = dvb_video_get_event(av7110, parg, file->f_flags);
1049 break; 1069 break;
1050 1070
1051 case VIDEO_GET_SIZE: 1071 case VIDEO_GET_SIZE:
@@ -1105,25 +1125,32 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
1105 case VIDEO_FAST_FORWARD: 1125 case VIDEO_FAST_FORWARD:
1106 //note: arg is ignored by firmware 1126 //note: arg is ignored by firmware
1107 if (av7110->playing & RP_VIDEO) 1127 if (av7110->playing & RP_VIDEO)
1108 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, 1128 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1109 __Scan_I, 2, AV_PES, 0); 1129 __Scan_I, 2, AV_PES, 0);
1110 else 1130 else
1111 vidcom(av7110, VIDEO_CMD_FFWD, arg); 1131 ret = vidcom(av7110, VIDEO_CMD_FFWD, arg);
1112 av7110->trickmode = TRICK_FAST; 1132 if (!ret) {
1113 av7110->videostate.play_state = VIDEO_PLAYING; 1133 av7110->trickmode = TRICK_FAST;
1134 av7110->videostate.play_state = VIDEO_PLAYING;
1135 }
1114 break; 1136 break;
1115 1137
1116 case VIDEO_SLOWMOTION: 1138 case VIDEO_SLOWMOTION:
1117 if (av7110->playing&RP_VIDEO) { 1139 if (av7110->playing&RP_VIDEO) {
1118 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Slow, 2, 0, 0); 1140 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Slow, 2, 0, 0);
1119 vidcom(av7110, VIDEO_CMD_SLOW, arg); 1141 if (!ret)
1142 ret = vidcom(av7110, VIDEO_CMD_SLOW, arg);
1120 } else { 1143 } else {
1121 vidcom(av7110, VIDEO_CMD_PLAY, 0); 1144 ret = vidcom(av7110, VIDEO_CMD_PLAY, 0);
1122 vidcom(av7110, VIDEO_CMD_STOP, 0); 1145 if (!ret)
1123 vidcom(av7110, VIDEO_CMD_SLOW, arg); 1146 ret = vidcom(av7110, VIDEO_CMD_STOP, 0);
1147 if (!ret)
1148 ret = vidcom(av7110, VIDEO_CMD_SLOW, arg);
1149 }
1150 if (!ret) {
1151 av7110->trickmode = TRICK_SLOW;
1152 av7110->videostate.play_state = VIDEO_PLAYING;
1124 } 1153 }
1125 av7110->trickmode = TRICK_SLOW;
1126 av7110->videostate.play_state = VIDEO_PLAYING;
1127 break; 1154 break;
1128 1155
1129 case VIDEO_GET_CAPABILITIES: 1156 case VIDEO_GET_CAPABILITIES:
@@ -1136,18 +1163,21 @@ static int dvb_video_ioctl(struct inode *inode, struct file *file,
1136 av7110_ipack_reset(&av7110->ipack[1]); 1163 av7110_ipack_reset(&av7110->ipack[1]);
1137 1164
1138 if (av7110->playing == RP_AV) { 1165 if (av7110->playing == RP_AV) {
1139 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, 1166 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1140 __Play, 2, AV_PES, 0); 1167 __Play, 2, AV_PES, 0);
1168 if (ret)
1169 break;
1141 if (av7110->trickmode == TRICK_FAST) 1170 if (av7110->trickmode == TRICK_FAST)
1142 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, 1171 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1143 __Scan_I, 2, AV_PES, 0); 1172 __Scan_I, 2, AV_PES, 0);
1144 if (av7110->trickmode == TRICK_SLOW) { 1173 if (av7110->trickmode == TRICK_SLOW) {
1145 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, 1174 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1146 __Slow, 2, 0, 0); 1175 __Slow, 2, 0, 0);
1147 vidcom(av7110, VIDEO_CMD_SLOW, arg); 1176 if (!ret)
1177 ret = vidcom(av7110, VIDEO_CMD_SLOW, arg);
1148 } 1178 }
1149 if (av7110->trickmode == TRICK_FREEZE) 1179 if (av7110->trickmode == TRICK_FREEZE)
1150 vidcom(av7110, VIDEO_CMD_STOP, 1); 1180 ret = vidcom(av7110, VIDEO_CMD_STOP, 1);
1151 } 1181 }
1152 break; 1182 break;
1153 1183
@@ -1170,7 +1200,7 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1170 unsigned long arg = (unsigned long) parg; 1200 unsigned long arg = (unsigned long) parg;
1171 int ret = 0; 1201 int ret = 0;
1172 1202
1173 dprintk(2, "av7110:%p, \n", av7110); 1203 dprintk(1, "av7110:%p, cmd=%04x\n", av7110,cmd);
1174 1204
1175 if (((file->f_flags & O_ACCMODE) == O_RDONLY) && 1205 if (((file->f_flags & O_ACCMODE) == O_RDONLY) &&
1176 (cmd != AUDIO_GET_STATUS)) 1206 (cmd != AUDIO_GET_STATUS))
@@ -1179,28 +1209,32 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1179 switch (cmd) { 1209 switch (cmd) {
1180 case AUDIO_STOP: 1210 case AUDIO_STOP:
1181 if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY) 1211 if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY)
1182 av7110_av_stop(av7110, RP_AUDIO); 1212 ret = av7110_av_stop(av7110, RP_AUDIO);
1183 else 1213 else
1184 audcom(av7110, AUDIO_CMD_MUTE); 1214 ret = audcom(av7110, AUDIO_CMD_MUTE);
1185 av7110->audiostate.play_state = AUDIO_STOPPED; 1215 if (!ret)
1216 av7110->audiostate.play_state = AUDIO_STOPPED;
1186 break; 1217 break;
1187 1218
1188 case AUDIO_PLAY: 1219 case AUDIO_PLAY:
1189 if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY) 1220 if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY)
1190 av7110_av_start_play(av7110, RP_AUDIO); 1221 ret = av7110_av_start_play(av7110, RP_AUDIO);
1191 audcom(av7110, AUDIO_CMD_UNMUTE); 1222 if (!ret)
1192 av7110->audiostate.play_state = AUDIO_PLAYING; 1223 ret = audcom(av7110, AUDIO_CMD_UNMUTE);
1224 if (!ret)
1225 av7110->audiostate.play_state = AUDIO_PLAYING;
1193 break; 1226 break;
1194 1227
1195 case AUDIO_PAUSE: 1228 case AUDIO_PAUSE:
1196 audcom(av7110, AUDIO_CMD_MUTE); 1229 ret = audcom(av7110, AUDIO_CMD_MUTE);
1197 av7110->audiostate.play_state = AUDIO_PAUSED; 1230 if (!ret)
1231 av7110->audiostate.play_state = AUDIO_PAUSED;
1198 break; 1232 break;
1199 1233
1200 case AUDIO_CONTINUE: 1234 case AUDIO_CONTINUE:
1201 if (av7110->audiostate.play_state == AUDIO_PAUSED) { 1235 if (av7110->audiostate.play_state == AUDIO_PAUSED) {
1202 av7110->audiostate.play_state = AUDIO_PLAYING; 1236 av7110->audiostate.play_state = AUDIO_PLAYING;
1203 audcom(av7110, AUDIO_CMD_UNMUTE | AUDIO_CMD_PCM16); 1237 ret = audcom(av7110, AUDIO_CMD_UNMUTE | AUDIO_CMD_PCM16);
1204 } 1238 }
1205 break; 1239 break;
1206 1240
@@ -1210,14 +1244,15 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1210 1244
1211 case AUDIO_SET_MUTE: 1245 case AUDIO_SET_MUTE:
1212 { 1246 {
1213 audcom(av7110, arg ? AUDIO_CMD_MUTE : AUDIO_CMD_UNMUTE); 1247 ret = audcom(av7110, arg ? AUDIO_CMD_MUTE : AUDIO_CMD_UNMUTE);
1214 av7110->audiostate.mute_state = (int) arg; 1248 if (!ret)
1249 av7110->audiostate.mute_state = (int) arg;
1215 break; 1250 break;
1216 } 1251 }
1217 1252
1218 case AUDIO_SET_AV_SYNC: 1253 case AUDIO_SET_AV_SYNC:
1219 av7110->audiostate.AV_sync_state = (int) arg; 1254 av7110->audiostate.AV_sync_state = (int) arg;
1220 audcom(av7110, arg ? AUDIO_CMD_SYNC_ON : AUDIO_CMD_SYNC_OFF); 1255 ret = audcom(av7110, arg ? AUDIO_CMD_SYNC_ON : AUDIO_CMD_SYNC_OFF);
1221 break; 1256 break;
1222 1257
1223 case AUDIO_SET_BYPASS_MODE: 1258 case AUDIO_SET_BYPASS_MODE:
@@ -1229,21 +1264,24 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1229 1264
1230 switch(av7110->audiostate.channel_select) { 1265 switch(av7110->audiostate.channel_select) {
1231 case AUDIO_STEREO: 1266 case AUDIO_STEREO:
1232 audcom(av7110, AUDIO_CMD_STEREO); 1267 ret = audcom(av7110, AUDIO_CMD_STEREO);
1233 if (av7110->adac_type == DVB_ADAC_CRYSTAL) 1268 if (!ret)
1234 i2c_writereg(av7110, 0x20, 0x02, 0x49); 1269 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1270 i2c_writereg(av7110, 0x20, 0x02, 0x49);
1235 break; 1271 break;
1236 1272
1237 case AUDIO_MONO_LEFT: 1273 case AUDIO_MONO_LEFT:
1238 audcom(av7110, AUDIO_CMD_MONO_L); 1274 ret = audcom(av7110, AUDIO_CMD_MONO_L);
1239 if (av7110->adac_type == DVB_ADAC_CRYSTAL) 1275 if (!ret)
1240 i2c_writereg(av7110, 0x20, 0x02, 0x4a); 1276 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1277 i2c_writereg(av7110, 0x20, 0x02, 0x4a);
1241 break; 1278 break;
1242 1279
1243 case AUDIO_MONO_RIGHT: 1280 case AUDIO_MONO_RIGHT:
1244 audcom(av7110, AUDIO_CMD_MONO_R); 1281 ret = audcom(av7110, AUDIO_CMD_MONO_R);
1245 if (av7110->adac_type == DVB_ADAC_CRYSTAL) 1282 if (!ret)
1246 i2c_writereg(av7110, 0x20, 0x02, 0x45); 1283 if (av7110->adac_type == DVB_ADAC_CRYSTAL)
1284 i2c_writereg(av7110, 0x20, 0x02, 0x45);
1247 break; 1285 break;
1248 1286
1249 default: 1287 default:
@@ -1264,7 +1302,7 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1264 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout); 1302 dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
1265 av7110_ipack_reset(&av7110->ipack[0]); 1303 av7110_ipack_reset(&av7110->ipack[0]);
1266 if (av7110->playing == RP_AV) 1304 if (av7110->playing == RP_AV)
1267 av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, 1305 ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
1268 __Play, 2, AV_PES, 0); 1306 __Play, 2, AV_PES, 0);
1269 break; 1307 break;
1270 case AUDIO_SET_ID: 1308 case AUDIO_SET_ID:
@@ -1274,7 +1312,7 @@ static int dvb_audio_ioctl(struct inode *inode, struct file *file,
1274 { 1312 {
1275 struct audio_mixer *amix = (struct audio_mixer *)parg; 1313 struct audio_mixer *amix = (struct audio_mixer *)parg;
1276 1314
1277 av7110_set_volume(av7110, amix->volume_left, amix->volume_right); 1315 ret = av7110_set_volume(av7110, amix->volume_left, amix->volume_right);
1278 break; 1316 break;
1279 } 1317 }
1280 case AUDIO_SET_STREAMTYPE: 1318 case AUDIO_SET_STREAMTYPE:
diff --git a/drivers/media/dvb/ttpci/av7110_av.h b/drivers/media/dvb/ttpci/av7110_av.h
index cc5e7a7e87c3..45dc144b8b43 100644
--- a/drivers/media/dvb/ttpci/av7110_av.h
+++ b/drivers/media/dvb/ttpci/av7110_av.h
@@ -3,14 +3,14 @@
3 3
4struct av7110; 4struct av7110;
5 5
6extern void av7110_set_vidmode(struct av7110 *av7110, int mode); 6extern int av7110_set_vidmode(struct av7110 *av7110, int mode);
7 7
8extern int av7110_record_cb(struct dvb_filter_pes2ts *p2t, u8 *buf, size_t len); 8extern int av7110_record_cb(struct dvb_filter_pes2ts *p2t, u8 *buf, size_t len);
9extern int av7110_pes_play(void *dest, struct dvb_ringbuffer *buf, int dlen); 9extern int av7110_pes_play(void *dest, struct dvb_ringbuffer *buf, int dlen);
10extern int av7110_write_to_decoder(struct dvb_demux_feed *feed, const u8 *buf, size_t len); 10extern int av7110_write_to_decoder(struct dvb_demux_feed *feed, const u8 *buf, size_t len);
11 11
12extern int av7110_set_volume(struct av7110 *av7110, int volleft, int volright); 12extern int av7110_set_volume(struct av7110 *av7110, int volleft, int volright);
13extern void av7110_av_stop(struct av7110 *av7110, int av); 13extern int av7110_av_stop(struct av7110 *av7110, int av);
14extern int av7110_av_start_record(struct av7110 *av7110, int av, 14extern int av7110_av_start_record(struct av7110 *av7110, int av,
15 struct dvb_demux_feed *dvbdmxfeed); 15 struct dvb_demux_feed *dvbdmxfeed);
16extern int av7110_av_start_play(struct av7110 *av7110, int av); 16extern int av7110_av_start_play(struct av7110 *av7110, int av);
diff --git a/drivers/media/dvb/ttpci/av7110_hw.h b/drivers/media/dvb/ttpci/av7110_hw.h
index 52061e17c6dd..fedd20f9815d 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.h
+++ b/drivers/media/dvb/ttpci/av7110_hw.h
@@ -458,27 +458,27 @@ static inline int SendDAC(struct av7110 *av7110, u8 addr, u8 data)
458 return av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, AudioDAC, 2, addr, data); 458 return av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, AudioDAC, 2, addr, data);
459} 459}
460 460
461static inline void av7710_set_video_mode(struct av7110 *av7110, int mode) 461static inline int av7710_set_video_mode(struct av7110 *av7110, int mode)
462{ 462{
463 av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetVidMode, 1, mode); 463 return av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetVidMode, 1, mode);
464} 464}
465 465
466static int inline vidcom(struct av7110 *av7110, u32 com, u32 arg) 466static inline int vidcom(struct av7110 *av7110, u32 com, u32 arg)
467{ 467{
468 return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_VIDEO_COMMAND, 4, 468 return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_VIDEO_COMMAND, 4,
469 (com>>16), (com&0xffff), 469 (com>>16), (com&0xffff),
470 (arg>>16), (arg&0xffff)); 470 (arg>>16), (arg&0xffff));
471} 471}
472 472
473static int inline audcom(struct av7110 *av7110, u32 com) 473static inline int audcom(struct av7110 *av7110, u32 com)
474{ 474{
475 return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_AUDIO_COMMAND, 2, 475 return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_AUDIO_COMMAND, 2,
476 (com>>16), (com&0xffff)); 476 (com>>16), (com&0xffff));
477} 477}
478 478
479static inline void Set22K(struct av7110 *av7110, int state) 479static inline int Set22K(struct av7110 *av7110, int state)
480{ 480{
481 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, (state ? ON22K : OFF22K), 0); 481 return av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, (state ? ON22K : OFF22K), 0);
482} 482}
483 483
484 484