Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 45473 | Differences between
and this patch

Collapse All | Expand All

(-)ivtv/driver/ivtv-api.c (-137 / +371 lines)
Lines 4-14 Link Here
4
 * This file will hold API related functions, both internal (firmware api)
4
 * This file will hold API related functions, both internal (firmware api)
5
 * and external (v4l2, etc)
5
 * and external (v4l2, etc)
6
 *
6
 *
7
 * -----
8
 * MPG600/MPG160 support by  T.Adachi <tadachi@tadachi-net.com>
9
 *                      and Takeru KOMORIYA<komoriya@paken.org>
10
 *
11
 * AVerMedia M179 GPIO info by Chris Pinkham <cpinkham@bc2va.org> 
12
 *                using information provided by Jiun-Kuei Jung @ AVerMedia.
7
 */
13
 */
8
14
9
#include "ivtv.h"
15
#include "ivtv.h"
10
#include "audiochip.h"
16
#include "audiochip.h"
11
17
18
extern struct i2c_addresses_st ivtv_i2c_addresses[];
19
extern struct card_function_flag_st ivtv_card_flags[];
20
extern struct ivtv_gpio_data_st ivtv_gpio_data[];
21
extern struct ivtv_msp34xx_audio_map_st ivtv_msp34xx_audio_map[];
22
extern struct ivtv_card_params_st ivtv_card_params[];
23
12
/* Fix the v4l2 api breakage - need to define if still using the old api */
24
/* Fix the v4l2 api breakage - need to define if still using the old api */
13
#ifndef VIDIOC_OVERLAY_OLD
25
#ifndef VIDIOC_OVERLAY_OLD
14
#define VIDIOC_OVERLAY_OLD		_IOWR ('V', 14, int)
26
#define VIDIOC_OVERLAY_OLD		_IOWR ('V', 14, int)
Lines 33-38 Link Here
33
static int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp,
45
static int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp,
34
			   unsigned int cmd, unsigned long arg);
46
			   unsigned int cmd, unsigned long arg);
35
static int ivtv_v4l2_pre_init(struct ivtv *itv);
47
static int ivtv_v4l2_pre_init(struct ivtv *itv);
48
static int ivtv_set_audio_for_msp34xx(struct ivtv *itv);
49
static int ivtv_set_audio_for_gpio(struct ivtv *itv);
36
50
37
struct file_operations ivtv_v4l2_fops = {
51
struct file_operations ivtv_v4l2_fops = {
38
	owner:		THIS_MODULE,
52
	owner:		THIS_MODULE,
Lines 65-71 Link Here
65
	.index		= 0,
79
	.index		= 0,
66
	.name		= "ivtv TV Tuner",
80
	.name		= "ivtv TV Tuner",
67
	.type		= V4L2_TUNER_ANALOG_TV,
81
	.type		= V4L2_TUNER_ANALOG_TV,
68
	.capability	= (V4L2_TUNER_CAP_NORM|V4L2_TUNER_CAP_STEREO),
82
	.capability	= (V4L2_TUNER_CAP_NORM|V4L2_TUNER_CAP_STEREO
83
			   |V4L2_TUNER_CAP_LANG1|V4L2_TUNER_CAP_LANG2),
69
	.rxsubchans	= (V4L2_TUNER_SUB_STEREO),
84
	.rxsubchans	= (V4L2_TUNER_SUB_STEREO),
70
	.audmode	= V4L2_TUNER_MODE_STEREO,
85
	.audmode	= V4L2_TUNER_MODE_STEREO,
71
	.signal		= 0,
86
	.signal		= 0,
Lines 102-108 Link Here
102
	}
117
	}
103
};
118
};
104
119
105
struct v4l2_input tmk_inputs[10] = { /*values that work with the author's card */
120
struct v4l2_input tmk_pvr_inputs[10] = { /*values that work with the author's card */
106
	{
121
	{
107
	.index		= 0,
122
	.index		= 0,
108
	.name		= "Composite 0",
123
	.name		= "Composite 0",
Lines 176-181 Link Here
176
	}
191
	}
177
};
192
};
178
193
194
struct v4l2_input tmk_mpg_inputs[5] = { /* MPG600/MPG160/M179 */
195
      {
196
      .index          = 0,
197
      .name           = "S-Video 0",
198
      .type           = V4L2_INPUT_TYPE_CAMERA,
199
      .audioset       = 1,
200
      .tuner          = 0,
201
      .status         = 0,
202
      },{
203
      .index          = 1,
204
      .name           = "N/A",
205
      .type           = V4L2_INPUT_TYPE_CAMERA,
206
      .audioset       = 1,
207
      .tuner          = 0,
208
      .status         = 0,
209
      },{
210
      .index          = 2,
211
      .name           = "N/A",
212
      .type           = V4L2_INPUT_TYPE_CAMERA,
213
      .audioset       = 1,
214
      .tuner          = 0,
215
      .status         = 0,
216
      },{
217
      .index          = 3,
218
      .name           = "Composite 0",
219
      .type           = V4L2_INPUT_TYPE_CAMERA,
220
      .audioset       = 1,
221
      .tuner          = 0,
222
      .status         = 0,
223
      },{
224
      .index          = 4,
225
      .name           = "Tuner 0",
226
      .type           = V4L2_INPUT_TYPE_TUNER,
227
      .audioset       = 0,
228
      .tuner          = 0,
229
      .status         = 0,
230
      }
231
};
232
233
179
//FIXME capability and mode might be wrong
234
//FIXME capability and mode might be wrong
180
struct v4l2_audio tmk_audio_inputs[3] = {
235
struct v4l2_audio tmk_audio_inputs[3] = {
181
	{0,"Tv Tuner Audio In",0,0,},
236
	{0,"Tv Tuner Audio In",0,0,},
Lines 183-195 Link Here
183
	{2,"Radio Tuner Audio In", 0,0,},
238
	{2,"Radio Tuner Audio In", 0,0,},
184
};
239
};
185
240
186
int tmk_audio_mapping[] = {
187
	0,3, /* Input 0 is msp input 3 */
188
	1,1, /* input 1 is msp input 1 */
189
	2,2, /* Input 2 is msp input 2 */
190
	0,0  /* you're at end of list! */
191
};
192
193
struct v4l2_queryctrl ivtv_ctrl_menu_freq = {
241
struct v4l2_queryctrl ivtv_ctrl_menu_freq = {
194
		.id		= V4L2_CID_IVTV_FREQ,
242
		.id		= V4L2_CID_IVTV_FREQ,
195
		.type		= V4L2_CTRL_TYPE_MENU, 
243
		.type		= V4L2_CTRL_TYPE_MENU, 
Lines 211-219 Link Here
211
259
212
u32 ivtv_audio_tbl_freq[] = {
260
u32 ivtv_audio_tbl_freq[] = {
213
	/* setting */
261
	/* setting */
214
	0x2 /* 32kHz   binary 10 */,
262
	IVTV_AUDIO_32000 /* 32kHz   binary 10 */,
215
	0x0 /* 44.1kHz binary 00 */,
263
	IVTV_AUDIO_44100 /* 44.1kHz binary 00 */,
216
	0x1 /* 48kHz   binary 01 */
264
	IVTV_AUDIO_48000 /* 48kHz   binary 01 */
217
};
265
};
218
266
219
u32 ivtv_audio_mask_freq = 0x3;
267
u32 ivtv_audio_mask_freq = 0x3;
Lines 710-745 Link Here
710
/* Initialize v4l2 variables and register v4l2 device */
758
/* Initialize v4l2 variables and register v4l2 device */
711
int ivtv_v4l2_setup(struct ivtv *itv) {
759
int ivtv_v4l2_setup(struct ivtv *itv) {
712
	int x, cont, retval;
760
	int x, cont, retval;
713
	
714
	IVTV_DEBUG(IVTV_DEBUG_INFO,"v4l2 setup\n");
715
761
716
	//switch based on card type
762
	IVTV_DEBUG(IVTV_DEBUG_INFO,"v4l2 setup\n");
717
	//  and fill in appropriate v4l2 device
763
      /* fill in appropriate v4l2 device */
718
	switch (itv->card_type) {
764
      IVTV_DEBUG(IVTV_DEBUG_INFO,"Configuring %s card\n",
719
	case IVTV_350_V1:
765
                 ivtv_card_params[itv->card_type].card_name);
720
		IVTV_DEBUG(IVTV_DEBUG_INFO,"Configuring 350rev1 card\n");
766
      itv->v4l2.streamcount = ivtv_card_params[itv->card_type].stream_count;
721
		itv->v4l2.streamcount = IVTV_350_V1_STREAMS;
767
      /* Disable dec yuv buffers if requested */
722
		/* Disable dec yuv buffers if requested */
768
      if (((itv->card_type == IVTV_350_V1) || (itv->card_type == IVTV_350_V2))
723
		if (itv->options.dec_yuv_buffers == 0) itv->v4l2.streamcount--;
769
          && (itv->options.dec_yuv_buffers == 0)) {
724
		itv->v4l2.capabilities = (V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_TUNER|
770
              itv->v4l2.streamcount--;
725
					  V4L2_CAP_AUDIO|V4L2_CAP_READWRITE|V4L2_CAP_VBI_CAPTURE|
726
					  V4L2_CAP_VIDEO_OUTPUT|V4L2_CAP_RADIO);
727
		break;
728
	case IVTV_250_V2:
729
		IVTV_DEBUG(IVTV_DEBUG_INFO,"Configuring 250rev2 card\n");
730
		itv->v4l2.streamcount = IVTV_250_V2_STREAMS;
731
		itv->v4l2.capabilities = (V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_TUNER|
732
					  V4L2_CAP_AUDIO|V4L2_CAP_READWRITE|V4L2_CAP_VBI_CAPTURE);
733
		break;
734
	case IVTV_250_V1:
735
		IVTV_DEBUG(IVTV_DEBUG_INFO,"Configuring 250rev1 card\n");
736
	default: /* shouldn't happen, treat like V1 */
737
		itv->v4l2.streamcount = IVTV_250_V1_STREAMS;
738
		itv->v4l2.capabilities = (V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_TUNER|
739
					  V4L2_CAP_AUDIO|V4L2_CAP_READWRITE|V4L2_CAP_VBI_CAPTURE);
740
		
741
		break;
742
	}
771
	}
772
      itv->v4l2.capabilities = ivtv_card_params[itv->card_type].capabilities;
743
773
744
        /* Initial settings */
774
        /* Initial settings */
745
        itv->v4l2.codec.bitrate_mode	= 0;
775
        itv->v4l2.codec.bitrate_mode	= 0;
Lines 768-774 Link Here
768
	itv->dec_options.speed.fr_field	= 1;
798
	itv->dec_options.speed.fr_field	= 1;
769
	itv->dec_options.decbuffers	= 1;
799
	itv->dec_options.decbuffers	= 1;
770
	itv->dec_options.prebuffer	= 1;
800
	itv->dec_options.prebuffer	= 1;
771
		
801
772
	/* Allocate streams */
802
	/* Allocate streams */
773
        itv->v4l2.streams = (struct ivtv_v4l2_stream *)
803
        itv->v4l2.streams = (struct ivtv_v4l2_stream *)
774
                        kmalloc((itv->v4l2.streamcount *
804
                        kmalloc((itv->v4l2.streamcount *
Lines 800-808 Link Here
800
	memcpy(&itv->v4l2.streams[IVTV_ENC_STREAM_TYPE_PCM], &tmk_pcm_stream,
830
	memcpy(&itv->v4l2.streams[IVTV_ENC_STREAM_TYPE_PCM], &tmk_pcm_stream,
801
               sizeof(struct ivtv_v4l2_stream));
831
               sizeof(struct ivtv_v4l2_stream));
802
832
803
	/* Set some card-specific per-stream stuff here */	
833
	/* Set some card-specific per-stream stuff here */
804
	switch (itv->card_type) { 
834
	switch (itv->card_type) {
805
        case IVTV_350_V1:
835
        case IVTV_350_V1:
836
        case IVTV_350_V2:
806
	       	memcpy(&itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_MPG], &dec_mpg_stream,
837
	       	memcpy(&itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_MPG], &dec_mpg_stream,
807
        	       sizeof(struct ivtv_v4l2_stream));
838
        	       sizeof(struct ivtv_v4l2_stream));
808
       		memcpy(&itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_VBI], &dec_vbi_stream,
839
       		memcpy(&itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_VBI], &dec_vbi_stream,
Lines 815-823 Link Here
815
        		       sizeof(struct ivtv_v4l2_stream));
846
        		       sizeof(struct ivtv_v4l2_stream));
816
		}
847
		}
817
		break;
848
		break;
849
	case IVTV_MPG600:
850
		break;
851
	case IVTV_MPG160:
852
		break;
853
        case IVTV_M179:
854
		break;
818
        case IVTV_250_V2:
855
        case IVTV_250_V2:
856
        case IVTV_250_V4:
819
		break;
857
		break;
820
        case IVTV_250_V1:
858
        case IVTV_250_V1:
859
        case IVTV_250_V3:
860
		break;
821
        default: /* shouldn't happen, treat like V1 */
861
        default: /* shouldn't happen, treat like V1 */
822
		break;
862
		break;
823
	}
863
	}
Lines 893-905 Link Here
893
	/* Set any card-specific per-stream stuff here */	
933
	/* Set any card-specific per-stream stuff here */	
894
	switch (itv->card_type) { 
934
	switch (itv->card_type) { 
895
        case IVTV_350_V1:
935
        case IVTV_350_V1:
936
        case IVTV_350_V2:
896
		/* allocate buffers for decoder */
937
		/* allocate buffers for decoder */
897
	        x = ivtv_init_queue(itv,
938
	        x = ivtv_init_queue(itv,
898
			&itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_MPG].free_q,
939
			&itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_MPG].free_q,
899
		       	itv->options.dec_mpg_buffers,
940
		       	itv->options.dec_mpg_buffers,
900
			itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_MPG].format.type);
941
			itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_MPG].format.type);
901
		
942
902
		itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_MPG].v4l2dev->minor = 
943
		itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_MPG].v4l2dev->minor =
903
			itv->num + IVTV_V4L2_DEC_OFFSET;
944
			itv->num + IVTV_V4L2_DEC_OFFSET;
904
		set_bit(IVTV_F_S_UNINIT, &itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_MPG].s_flags);
945
		set_bit(IVTV_F_S_UNINIT, &itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_MPG].s_flags);
905
946
Lines 924-932 Link Here
924
		        x = ivtv_init_queue(itv,
965
		        x = ivtv_init_queue(itv,
925
				&itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_YUV].free_q,
966
				&itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_YUV].free_q,
926
			       	itv->options.dec_yuv_buffers,
967
			       	itv->options.dec_yuv_buffers,
927
				itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_YUV].format.type);
968
  				itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_YUV].format.type);
928
969
929
			itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_YUV].v4l2dev->minor = 
970
                        itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_YUV].v4l2dev->minor =
930
				itv->num + IVTV_V4L2_YUV_OFFSET + IVTV_V4L2_DEC_OFFSET;
971
				itv->num + IVTV_V4L2_YUV_OFFSET + IVTV_V4L2_DEC_OFFSET;
931
			set_bit(IVTV_F_S_UNINIT, &itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_YUV].s_flags);
972
			set_bit(IVTV_F_S_UNINIT, &itv->v4l2.streams[IVTV_DEC_STREAM_TYPE_YUV].s_flags);
932
		}
973
		}
Lines 938-945 Link Here
938
979
939
		break;
980
		break;
940
        case IVTV_250_V2:
981
        case IVTV_250_V2:
982
        case IVTV_250_V4:
941
		break;
983
		break;
942
        case IVTV_250_V1:
984
        case IVTV_250_V1:
985
        case IVTV_250_V3:
986
		break;
943
        default: /* shouldn't happen, treat like V1 */
987
        default: /* shouldn't happen, treat like V1 */
944
		break;
988
		break;
945
	}
989
	}
Lines 991-1016 Link Here
991
1035
992
/* After setting the audio.active param, call this to
1036
/* After setting the audio.active param, call this to
993
 *  get the right input.. think of it as a resolver */
1037
 *  get the right input.. think of it as a resolver */
994
int ivtv_set_audio(struct ivtv *itv, int *map) {
1038
int ivtv_set_audio(struct ivtv *itv) {
995
	int input,msp_input;
1039
	switch (ivtv_card_flags[itv->card_type].audio_selector) {
996
	struct msp_matrix mspm;
1040
	case USE_MSP34XX:
1041
		return ivtv_set_audio_for_msp34xx(itv);
1042
	case USE_GPIO:
1043
		return ivtv_set_audio_for_gpio(itv);
1044
	}
997
1045
998
	do {
1046
	IVTV_DEBUG(IVTV_DEBUG_ERR,"Invalid card type [ivtv_set_audio]!\n");
999
		input = *(map++);
1047
	return -EINVAL;
1000
		msp_input = *(map++);
1048
}
1001
		if (input == itv->v4l2.audio.active) {
1049
1002
			IVTV_DEBUG(IVTV_DEBUG_INFO,
1050
/* switching audio input for WIN-PVR250/350 and MSP34XX based card */
1003
				   "Setting audio to input %d\n", msp_input);
1051
static int ivtv_set_audio_for_msp34xx(struct ivtv *itv)
1004
			mspm.input = msp_input;
1052
{
1005
			mspm.output = itv->v4l2.audio_output;
1053
        struct msp_matrix mspm;
1006
1054
1007
			ivtv_call_i2c_client(itv,
1055
	if (itv->v4l2.audio.active <= 1) {
1008
					     IVTV_MSP3400_I2C_ADDR,
1056
		IVTV_DEBUG(IVTV_DEBUG_INFO,
1009
					     MSP_SET_MATRIX,
1057
			   "Setting audio to input %d\n", itv->v4l2.audio.active);
1010
					     &mspm);
1058
		mspm.output = itv->v4l2.audio_output;
1011
			return 0;
1059
		switch (itv->v4l2.audio.active) {
1060
		case 0: /* Tuner Audio */
1061
			mspm.input = ivtv_msp34xx_audio_map[itv->card_type].tuner;
1062
			break;
1063
		case 1: /* Audio-In (Line-in) */
1064
			mspm.input = ivtv_msp34xx_audio_map[itv->card_type].line;
1065
			break;
1012
		}
1066
		}
1013
	} while ((msp_input !=0) || (input != 0));
1067
		ivtv_call_i2c_client(itv,
1068
				     ivtv_i2c_addresses[itv->card_type].msp34xx_addr,
1069
				     MSP_SET_MATRIX,
1070
				     &mspm);
1071
		return 0;
1072
	}
1073
1074
	IVTV_DEBUG(IVTV_DEBUG_ERR,"Invalid audio input, shouldn't happen!\n");
1075
1076
	return -EINVAL;
1077
}
1078
1079
1080
1081
1082
/* switching audio input for MPG600/MPG160/M179 (controlled by GPIO) */
1083
static int ivtv_set_audio_for_gpio(struct ivtv *itv)
1084
{
1085
	if (itv->v4l2.audio.active <= 1) {
1086
		IVTV_DEBUG(IVTV_DEBUG_INFO,
1087
			   "Setting audio to input %d\n", itv->v4l2.audio.active);
1088
		switch (itv->v4l2.audio.active) {
1089
		case 0: /* Tuner Audio */
1090
			ivtv_set_gpio_audio(itv,IVTV_GPIO_AUDIO_TUNER);
1091
			break;
1092
		case 1: /* Audio-In (Line-in) */
1093
			ivtv_set_gpio_audio(itv,IVTV_GPIO_AUDIO_LINE);
1094
			break;;
1095
		}
1096
		ivtv_set_gpio_audio(itv,IVTV_GPIO_AUDIO_UNMUTE);
1097
		return 0;
1098
	}
1014
1099
1015
	IVTV_DEBUG(IVTV_DEBUG_ERR,"Invalid audio input, shouldn't happen!\n");
1100
	IVTV_DEBUG(IVTV_DEBUG_ERR,"Invalid audio input, shouldn't happen!\n");
1016
1101
Lines 1067-1075 Link Here
1067
1152
1068
	/* FIXME too much hardcoding? */
1153
	/* FIXME too much hardcoding? */
1069
	//inputs
1154
	//inputs
1070
	itv->v4l2.input.active	= 4; 
1155
	if ((itv->card_type == IVTV_MPG600)
1071
	itv->v4l2.input.count	= 10;
1156
	    ||(itv->card_type == IVTV_MPG160)
1072
	itv->v4l2.input.table.input	= tmk_inputs;
1157
		||(itv->card_type == IVTV_M179)) {
1158
		itv->v4l2.input.active	= 4; 
1159
		itv->v4l2.input.count	= 5;
1160
		itv->v4l2.input.table.input	= tmk_mpg_inputs;
1161
	} else {
1162
		itv->v4l2.input.active	= 4; 
1163
		itv->v4l2.input.count	= 10;
1164
		itv->v4l2.input.table.input	= tmk_pvr_inputs;
1165
	}
1073
1166
1074
	itv->v4l2.audio_output	= 1;
1167
	itv->v4l2.audio_output	= 1;
1075
1168
Lines 1205-1211 Link Here
1205
			itv->v4l2.audio_meta[x].table[temp];
1298
			itv->v4l2.audio_meta[x].table[temp];
1206
	}
1299
	}
1207
1300
1208
	retval = ivtv_set_audio(itv,tmk_audio_mapping);
1301
	retval = ivtv_set_audio(itv);
1209
	if (retval) {
1302
	if (retval) {
1210
		kfree(itv->v4l2.tuner.table.tuner);
1303
		kfree(itv->v4l2.tuner.table.tuner);
1211
		return retval;
1304
		return retval;
Lines 1220-1228 Link Here
1220
	struct msp_matrix mspm;
1313
	struct msp_matrix mspm;
1221
1314
1222
	/* Mute sound to avoid pop */
1315
	/* Mute sound to avoid pop */
1223
	mspm.input = 8;
1316
        switch (ivtv_card_flags[itv->card_type].audio_selector) {
1224
	mspm.output = itv->v4l2.audio_output;
1317
        case USE_MSP34XX:
1225
	ivtv_call_i2c_client(itv,IVTV_MSP3400_I2C_ADDR,MSP_SET_MATRIX,&mspm);
1318
        	mspm.input = 8;
1319
                mspm.output = itv->v4l2.audio_output;
1320
                ivtv_call_i2c_client(itv,
1321
                	ivtv_i2c_addresses[itv->card_type].msp34xx_addr,
1322
                        MSP_SET_MATRIX,&mspm);
1323
                break;
1324
        case USE_GPIO:
1325
        	ivtv_set_gpio_audio(itv,IVTV_GPIO_AUDIO_MUTE);
1326
        break;
1327
        }
1226
1328
1227
	if (0 != ivtv_pause_encoder(itv, 0)) 
1329
	if (0 != ivtv_pause_encoder(itv, 0)) 
1228
		IVTV_DEBUG(IVTV_DEBUG_ERR, "Mute: Error pausing stream\n");
1330
		IVTV_DEBUG(IVTV_DEBUG_ERR, "Mute: Error pausing stream\n");
Lines 1237-1243 Link Here
1237
		IVTV_DEBUG(IVTV_DEBUG_ERR, "Unmute: Error unpausing stream\n");
1339
		IVTV_DEBUG(IVTV_DEBUG_ERR, "Unmute: Error unpausing stream\n");
1238
1340
1239
	/* Unmute */
1341
	/* Unmute */
1240
	ivtv_set_audio(itv,tmk_audio_mapping);
1342
	ivtv_set_audio(itv);
1241
}
1343
}
1242
1344
1243
static void ivtv_select_vbi_line(struct ivtv *itv, unsigned long line, int enable, int slicing)
1345
static void ivtv_select_vbi_line(struct ivtv *itv, unsigned long line, int enable, int slicing)
Lines 1483-1489 Link Here
1483
		/* Disable digitizer (saa7115) */
1585
		/* Disable digitizer (saa7115) */
1484
		IVTV_DEBUG(IVTV_DEBUG_INFO, "Disabling digitizer\n");
1586
		IVTV_DEBUG(IVTV_DEBUG_INFO, "Disabling digitizer\n");
1485
		dig=0;
1587
		dig=0;
1486
		ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,
1588
		ivtv_call_i2c_client(itv,
1589
				     ivtv_i2c_addresses[itv->card_type].saa7115_addr,
1487
				     DECODER_ENABLE_OUTPUT,&dig);
1590
				     DECODER_ENABLE_OUTPUT,&dig);
1488
		// setup VBI registers
1591
		// setup VBI registers
1489
		ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,
1592
		ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,
Lines 1598-1604 Link Here
1598
		/* enable digitizer (saa7115) */
1701
		/* enable digitizer (saa7115) */
1599
		IVTV_DEBUG(IVTV_DEBUG_INFO, "Enabling digitizer\n");
1702
		IVTV_DEBUG(IVTV_DEBUG_INFO, "Enabling digitizer\n");
1600
		dig=1;
1703
		dig=1;
1601
		ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,
1704
		ivtv_call_i2c_client(itv,
1705
				     ivtv_i2c_addresses[itv->card_type].saa7115_addr,
1602
				     DECODER_ENABLE_OUTPUT,&dig);
1706
				     DECODER_ENABLE_OUTPUT,&dig);
1603
	
1707
	
1604
		IVTV_DEBUG(IVTV_DEBUG_INFO, "Sleeping for 100ms\n");
1708
		IVTV_DEBUG(IVTV_DEBUG_INFO, "Sleeping for 100ms\n");
Lines 2189-2201 Link Here
2189
	case SAA7115_GET_REG: {
2293
	case SAA7115_GET_REG: {
2190
		struct saa7115_reg_t *saa7115_reg = (struct saa7115_reg_t *)arg;
2294
		struct saa7115_reg_t *saa7115_reg = (struct saa7115_reg_t *)arg;
2191
2295
2192
		ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,SAA7115_GET_REG,saa7115_reg);
2296
		ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
2297
				     SAA7115_GET_REG,saa7115_reg);
2193
		break;
2298
		break;
2194
	}
2299
	}
2195
	case SAA7115_SET_REG: {
2300
	case SAA7115_SET_REG: {
2196
		struct saa7115_reg_t *saa7115_reg = (struct saa7115_reg_t *)arg;
2301
		struct saa7115_reg_t *saa7115_reg = (struct saa7115_reg_t *)arg;
2197
2302
2198
                ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,SAA7115_SET_REG,saa7115_reg);
2303
                ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
2304
				     SAA7115_SET_REG,saa7115_reg);
2199
		break;
2305
		break;
2200
	}
2306
	}
2201
#endif
2307
#endif
Lines 2727-2733 Link Here
2727
						int vrate = (int)v;
2833
						int vrate = (int)v;
2728
						/* FIXME not obvious how this works
2834
						/* FIXME not obvious how this works
2729
						 *  (see ivtv_ctrl_query_freq[]) */
2835
						 *  (see ivtv_ctrl_query_freq[]) */
2730
						ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_SET_AUDIO,&vrate);
2836
						ivtv_call_i2c_client(itv,
2837
								     ivtv_i2c_addresses[itv->card_type].saa7115_addr,
2838
								     DECODER_SET_AUDIO,&vrate);
2731
					}
2839
					}
2732
				} else {
2840
				} else {
2733
					IVTV_DEBUG(IVTV_DEBUG_ERR,
2841
					IVTV_DEBUG(IVTV_DEBUG_ERR,
Lines 2782-2790 Link Here
2782
				IVTV_DEBUG(IVTV_DEBUG_ERR, "ctrl: invalid brightness value: %d\n", vctrl->value);
2890
				IVTV_DEBUG(IVTV_DEBUG_ERR, "ctrl: invalid brightness value: %d\n", vctrl->value);
2783
				return -EINVAL;
2891
				return -EINVAL;
2784
			}
2892
			}
2785
			ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_GET_PICTURE,&pic);
2893
			ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
2894
					     DECODER_GET_PICTURE,&pic);
2786
			pic.bright = vctrl->value;
2895
			pic.bright = vctrl->value;
2787
			ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_SET_PICTURE,&pic);
2896
			ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
2897
					     DECODER_SET_PICTURE,&pic);
2788
			break;
2898
			break;
2789
		}
2899
		}
2790
		case V4L2_CID_HUE: {
2900
		case V4L2_CID_HUE: {
Lines 2794-2802 Link Here
2794
				IVTV_DEBUG(IVTV_DEBUG_ERR, "ctrl: invalid hue value: %d\n", vctrl->value);
2904
				IVTV_DEBUG(IVTV_DEBUG_ERR, "ctrl: invalid hue value: %d\n", vctrl->value);
2795
				return -EINVAL;
2905
				return -EINVAL;
2796
			}
2906
			}
2797
			ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_GET_PICTURE,&pic);
2907
			ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
2908
					     DECODER_GET_PICTURE,&pic);
2798
			pic.hue = vctrl->value;
2909
			pic.hue = vctrl->value;
2799
			ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_SET_PICTURE,&pic);
2910
			ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
2911
					     DECODER_SET_PICTURE,&pic);
2800
			break;
2912
			break;
2801
		}
2913
		}
2802
		case V4L2_CID_SATURATION: {
2914
		case V4L2_CID_SATURATION: {
Lines 2806-2814 Link Here
2806
				IVTV_DEBUG(IVTV_DEBUG_ERR, "ctrl: invalid saturation value: %d\n", vctrl->value);
2918
				IVTV_DEBUG(IVTV_DEBUG_ERR, "ctrl: invalid saturation value: %d\n", vctrl->value);
2807
				return -EINVAL;
2919
				return -EINVAL;
2808
			}
2920
			}
2809
			ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_GET_PICTURE,&pic);
2921
			ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
2922
					     DECODER_GET_PICTURE,&pic);
2810
			pic.sat = vctrl->value;
2923
			pic.sat = vctrl->value;
2811
			ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_SET_PICTURE,&pic);
2924
			ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
2925
					     DECODER_SET_PICTURE,&pic);
2812
			break;
2926
			break;
2813
		}
2927
		}
2814
		case V4L2_CID_CONTRAST: {
2928
		case V4L2_CID_CONTRAST: {
Lines 2818-2826 Link Here
2818
				IVTV_DEBUG(IVTV_DEBUG_ERR, "ctrl: invalid contrast value: %d\n", vctrl->value);
2932
				IVTV_DEBUG(IVTV_DEBUG_ERR, "ctrl: invalid contrast value: %d\n", vctrl->value);
2819
				return -EINVAL;
2933
				return -EINVAL;
2820
			}
2934
			}
2821
			ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_GET_PICTURE,&pic);
2935
			ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
2936
					     DECODER_GET_PICTURE,&pic);
2822
			pic.contrast = vctrl->value;
2937
			pic.contrast = vctrl->value;
2823
			ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_SET_PICTURE,&pic);
2938
			ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
2939
					     DECODER_SET_PICTURE,&pic);
2824
			break;
2940
			break;
2825
		}
2941
		}
2826
		case V4L2_CID_AUDIO_VOLUME: {
2942
		case V4L2_CID_AUDIO_VOLUME: {
Lines 2830-2850 Link Here
2830
				IVTV_DEBUG(IVTV_DEBUG_ERR, "ctrl: invalid value for volume: %d", vctrl->value);
2946
				IVTV_DEBUG(IVTV_DEBUG_ERR, "ctrl: invalid value for volume: %d", vctrl->value);
2831
				return -EINVAL;
2947
				return -EINVAL;
2832
			}
2948
			}
2833
			ivtv_call_i2c_client(itv,IVTV_MSP3400_I2C_ADDR,VIDIOCGAUDIO,&va);
2949
			switch (ivtv_card_flags[itv->card_type].audio_selector)
2834
			va.volume = vctrl->value;
2950
{
2835
			va.mode = 0;  /* keep stereo mode at automatic stereo detection */
2951
			case USE_MSP34XX:
2836
			ivtv_call_i2c_client(itv,IVTV_MSP3400_I2C_ADDR,VIDIOCSAUDIO,&va);
2952
                              ivtv_call_i2c_client(itv,
2953
                                                   ivtv_i2c_addresses[itv->card_type].msp34xx_addr,
2954
                                                   VIDIOCGAUDIO,&va);
2955
                              va.volume = vctrl->value;
2956
			      va.mode = 0;  /* keep stereo mode at automatic stereo detection */
2957
                              ivtv_call_i2c_client(itv,
2958
                                                   ivtv_i2c_addresses[itv->card_type].msp34xx_addr,
2959
                                                   VIDIOCSAUDIO,&va);
2960
                              break;
2961
                      case USE_GPIO:
2962
                              /* do nothing (MPG600 etc) */
2963
                              break;
2964
                      }
2965
2837
			break;
2966
			break;
2838
		}
2967
		}
2839
		case V4L2_CID_AUDIO_MUTE: {
2968
		case V4L2_CID_AUDIO_MUTE: {
2840
			struct video_audio va;
2969
			struct video_audio va;
2841
			ivtv_call_i2c_client(itv,IVTV_MSP3400_I2C_ADDR,VIDIOCGAUDIO,&va);
2970
                      switch (ivtv_card_flags[itv->card_type].audio_selector) {
2842
			if (vctrl->value)
2971
                      case USE_MSP34XX:
2843
				va.flags |= VIDEO_AUDIO_MUTE;
2972
                              ivtv_call_i2c_client(itv,
2844
			else
2973
                                                   ivtv_i2c_addresses[itv->card_type].msp34xx_addr,
2845
				va.flags = (va.flags & ~(VIDEO_AUDIO_MUTE));
2974
                                                   VIDIOCGAUDIO,&va);
2846
			va.mode = 0;  /* keep stereo mode at automatic stereo detection */
2975
                              if (vctrl->value)
2847
			ivtv_call_i2c_client(itv,IVTV_MSP3400_I2C_ADDR,VIDIOCSAUDIO,&va);
2976
                                      va.flags |= VIDEO_AUDIO_MUTE;
2977
                              else
2978
                                      va.flags = (va.flags & ~(VIDEO_AUDIO_MUTE));
2979
				      va.mode = 0;  /* keep stereo mode at automatic stereo detection */
2980
                              ivtv_call_i2c_client(itv,
2981
                                                   ivtv_i2c_addresses[itv->card_type].msp34xx_addr,
2982
                                                   VIDIOCSAUDIO,&va);
2983
                              break;
2984
                      case USE_GPIO:
2985
                              if (vctrl->value) {
2986
                                      va.flags |= VIDEO_AUDIO_MUTE;
2987
                                      ivtv_set_gpio_audio(itv,IVTV_GPIO_AUDIO_MUTE);
2988
                              } else {
2989
                                      va.flags = (va.flags & ~(VIDEO_AUDIO_MUTE));
2990
                                      ivtv_set_gpio_audio(itv,IVTV_GPIO_AUDIO_UNMUTE);
2991
                              }
2992
                              break;
2993
                      }
2994
2848
			break;
2995
			break;
2849
		}
2996
		}
2850
		default:
2997
		default:
Lines 2900-2936 Link Here
2900
		switch (vctrl->id) {
3047
		switch (vctrl->id) {
2901
		case V4L2_CID_BRIGHTNESS: {
3048
		case V4L2_CID_BRIGHTNESS: {
2902
			struct saa7114 pic;
3049
			struct saa7114 pic;
2903
			ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_GET_PICTURE,&pic);
3050
			ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
3051
					     DECODER_GET_PICTURE,&pic);
2904
			vctrl->value = pic.bright;
3052
			vctrl->value = pic.bright;
2905
			break;
3053
			break;
2906
		}
3054
		}
2907
		case V4L2_CID_HUE: {
3055
		case V4L2_CID_HUE: {
2908
			struct saa7114 pic;
3056
			struct saa7114 pic;
2909
			ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_GET_PICTURE,&pic);
3057
			ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
3058
					     DECODER_GET_PICTURE,&pic);
2910
			vctrl->value = pic.hue;
3059
			vctrl->value = pic.hue;
2911
			break;
3060
			break;
2912
		}
3061
		}
2913
		case V4L2_CID_SATURATION: {
3062
		case V4L2_CID_SATURATION: {
2914
			struct saa7114 pic;
3063
			struct saa7114 pic;
2915
			ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_GET_PICTURE,&pic);
3064
			ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
3065
					     DECODER_GET_PICTURE,&pic);
2916
			vctrl->value = pic.sat;
3066
			vctrl->value = pic.sat;
2917
			break;
3067
			break;
2918
		}
3068
		}
2919
		case V4L2_CID_CONTRAST: {
3069
		case V4L2_CID_CONTRAST: {
2920
			struct saa7114 pic;
3070
			struct saa7114 pic;
2921
			ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,DECODER_GET_PICTURE,&pic);
3071
			ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].saa7115_addr,
3072
					     DECODER_GET_PICTURE,&pic);
2922
			vctrl->value = pic.contrast;
3073
			vctrl->value = pic.contrast;
2923
			break;
3074
			break;
2924
		}
3075
		}
2925
		case V4L2_CID_AUDIO_VOLUME: {
3076
		case V4L2_CID_AUDIO_VOLUME: {
2926
			struct video_audio va;
3077
			struct video_audio va;
2927
			ivtv_call_i2c_client(itv,IVTV_MSP3400_I2C_ADDR,VIDIOCGAUDIO,&va);
3078
			switch (ivtv_card_flags[itv->card_type].audio_selector) {
3079
			case USE_MSP34XX:
3080
				ivtv_call_i2c_client(itv,
3081
						     ivtv_i2c_addresses[itv->card_type].msp34xx_addr,
3082
						     VIDIOCGAUDIO,&va);
3083
				break;
3084
			case USE_GPIO:
3085
				if (ivtv_card_flags[itv->card_type].vol_control) {
3086
					/* if you can control VOLUME, write code here */
3087
				} else {
3088
					/* do nothing (MPG600 etc) */
3089
					va.volume = 65535; /* dummy code */
3090
				}
3091
				break;
3092
			}
2928
			vctrl->value = va.volume;
3093
			vctrl->value = va.volume;
2929
			break;
3094
			break;
2930
		}
3095
		}
2931
		case V4L2_CID_AUDIO_MUTE: {
3096
		case V4L2_CID_AUDIO_MUTE: {
2932
			struct video_audio va;
3097
			struct video_audio va;
2933
			ivtv_call_i2c_client(itv,IVTV_MSP3400_I2C_ADDR,VIDIOCGAUDIO,&va);
3098
			switch (ivtv_card_flags[itv->card_type].audio_selector) {
3099
			case USE_MSP34XX:
3100
				ivtv_call_i2c_client(itv,
3101
						     ivtv_i2c_addresses[itv->card_type].msp34xx_addr,
3102
						     VIDIOCGAUDIO,&va);
3103
				break;
3104
			case USE_GPIO:
3105
				if (ivtv_card_flags[itv->card_type].vol_control) {
3106
					/* if you can control VOLUME, write code here */
3107
				} else {
3108
					/* MPG600 etc */
3109
					va.flags = 0;
3110
					if (ivtv_get_gpio_audio(itv,IVTV_GPIO_AUDIO_MUTE))
3111
						va.flags = VIDEO_AUDIO_MUTE;
3112
				}
3113
				break;
3114
			}
2934
			vctrl->value = (va.flags & VIDEO_AUDIO_MUTE);
3115
			vctrl->value = (va.flags & VIDEO_AUDIO_MUTE);
2935
			break;
3116
			break;
2936
		}
3117
		}
Lines 3035-3041 Link Here
3035
		/* FIXME only sets resolution for now */
3216
		/* FIXME only sets resolution for now */
3036
		wind.width = vfmt->fmt.pix.width;
3217
		wind.width = vfmt->fmt.pix.width;
3037
		wind.height = vfmt->fmt.pix.height;
3218
		wind.height = vfmt->fmt.pix.height;
3038
		ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,
3219
		ivtv_call_i2c_client(itv,
3220
				     ivtv_i2c_addresses[itv->card_type].saa7115_addr,
3039
				     DECODER_SET_SIZE,&wind);
3221
				     DECODER_SET_SIZE,&wind);
3040
3222
3041
		/* FIXME switch on stream type, bounds checking */
3223
		/* FIXME switch on stream type, bounds checking */
Lines 3166-3179 Link Here
3166
3348
3167
				/* Tuner */
3349
				/* Tuner */
3168
				ivtv_call_i2c_client(itv,
3350
				ivtv_call_i2c_client(itv,
3169
						     IVTV_TUNER_I2C_ADDR,
3351
						     ivtv_i2c_addresses[itv->card_type].tuner_addr,
3170
						     VIDIOCSCHAN,&v);
3352
						     VIDIOCSCHAN,&v);
3353
3171
				/* Tuner Audio */
3354
				/* Tuner Audio */
3172
                                ivtv_call_i2c_client(itv,
3355
				switch (ivtv_card_flags[itv->card_type].audio_selector) {
3173
                                                     IVTV_MSP3400_I2C_ADDR,
3356
				case USE_MSP34XX:
3174
                                                     VIDIOCSCHAN,&v);
3357
					ivtv_call_i2c_client(itv,
3358
							     ivtv_i2c_addresses[itv->card_type].msp34xx_addr,
3359
							     VIDIOCSCHAN,&v);
3360
					break;
3361
				case USE_GPIO:
3362
					ivtv_set_gpio_audio(itv,IVTV_GPIO_AUDIO_TUNER);
3363
					break;
3364
				}
3365
3175
				/* Digitizer */
3366
				/* Digitizer */
3176
		                ivtv_call_i2c_client(itv,IVTV_SAA7115_I2C_ADDR,
3367
		                ivtv_call_i2c_client(itv,
3368
						     ivtv_i2c_addresses[itv->card_type].saa7115_addr,
3177
			                             DECODER_SET_NORM,&v.norm);
3369
			                             DECODER_SET_NORM,&v.norm);
3178
3370
3179
                                if (itv->v4l2.standard.active == 0) { // NTSC
3371
                                if (itv->v4l2.standard.active == 0) { // NTSC
Lines 3197-3205 Link Here
3197
3389
3198
		if ((vt->index < 0) || (vt->index >= itv->v4l2.tuner.count))
3390
		if ((vt->index < 0) || (vt->index >= itv->v4l2.tuner.count))
3199
			return -EINVAL;
3391
			return -EINVAL;
3200
		/* looks like tuner.c doesn't support selection 
3392
		if ((itv->card_type == IVTV_MPG600)
3201
		 * fallback to stereo... */
3393
		    ||(itv->card_type == IVTV_MPG160)
3202
		vt->audmode = V4L2_TUNER_MODE_STEREO;
3394
			||(itv->card_type == IVTV_M179)) {
3395
			ivtv_set_gpio_audiomode(itv,vt->audmode);
3396
		} else {
3397
			/* looks like tuner.c doesn't support selection 
3398
			 * fallback to stereo... */
3399
			vt->audmode = V4L2_TUNER_MODE_STEREO;
3400
		}
3203
3401
3204
		break;
3402
		break;
3205
	}
3403
	}
Lines 3241-3272 Link Here
3241
                        else {
3439
                        else {
3242
                                vt->signal = 0;
3440
                                vt->signal = 0;
3243
                        }
3441
                        }
3244
                }
3442
		}
3443
3444
              if ((itv->card_type == IVTV_MPG600)
3445
                  ||(itv->card_type == IVTV_MPG160)) {
3446
                      /* MPGxxx can read tuner audio status */
3447
                      switch (ivtv_get_gpio_audiomode(itv)) {
3448
                      case 0: /* mono */
3449
                              vt->rxsubchans = V4L2_TUNER_SUB_MONO;
3450
                              break;
3451
                      case 1: /* stereo */
3452
                              if ((vt->audmode == V4L2_TUNER_MODE_STEREO)
3453
                                  || (vt->audmode == V4L2_TUNER_MODE_LANG1))
3454
                                      vt->rxsubchans = V4L2_TUNER_SUB_STEREO;
3455
                              else
3456
                                      vt->rxsubchans = V4L2_TUNER_SUB_MONO;
3457
                              break;
3458
                      case 2: /* multiplex */
3459
                              if (vt->audmode == V4L2_TUNER_MODE_LANG2)
3460
                                      vt->rxsubchans = V4L2_TUNER_SUB_LANG2 | V4L2_TUNER_SUB_MONO;
3461
                              else
3462
                                      vt->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_MONO;
3463
                              break;
3464
                      }
3465
              }
3466
3245
		break;
3467
		break;
3246
	}
3468
	}
3247
	case MSP_SET_MATRIX: {
3469
	case MSP_SET_MATRIX: {
3248
		//FIXME copy_from_user needed
3470
		//FIXME copy_from_user needed
3249
		struct msp_matrix *mspm = (struct msp_matrix *)arg;
3471
		struct msp_matrix *mspm = (struct msp_matrix *)arg;
3250
3472
3251
		/* FIXME hardcoding! */
3473
              switch (ivtv_card_flags[itv->card_type].audio_selector) {
3252
		if ((mspm->input < 1) || (mspm->input > 8)) {
3474
              case USE_MSP34XX:
3253
			IVTV_DEBUG(IVTV_DEBUG_ERR,"Invalid audio input!\n");
3475
                      /* FIXME hardcoding! */
3254
			return -EINVAL;
3476
                      if ((mspm->input < 1) || (mspm->input > 8)) {
3255
		}
3477
                              IVTV_DEBUG(IVTV_DEBUG_ERR,"Invalid audio input!\n");
3256
		if ((mspm->output < 0) || (mspm->output >= 3)) {
3478
                              return -EINVAL;
3257
			IVTV_DEBUG(IVTV_DEBUG_ERR,"Invalid audio output!\n");
3479
                      }
3258
			return -EINVAL;
3480
                      if ((mspm->output < 0) || (mspm->output > 3)) {
3259
		}
3481
                              IVTV_DEBUG(IVTV_DEBUG_ERR,"Invalid audio output!\n");
3260
3482
                              return -EINVAL;
3261
		itv->v4l2.audio_output = mspm->output;
3483
                      }
3262
3484
                      itv->v4l2.audio_output = mspm->output;
3263
		IVTV_DEBUG(IVTV_DEBUG_INFO,
3485
3264
			   "v4l2 ioctl: set matrix in=%d,out=%d\n",
3486
                      IVTV_DEBUG(IVTV_DEBUG_INFO,
3265
			   mspm->input,
3487
                                 "v4l2 ioctl: set matrix in=%d,out=%d\n",
3266
			   mspm->output);
3488
                                 mspm->input,
3267
3489
                                 mspm->output);
3268
		ivtv_call_i2c_client(itv,IVTV_MSP3400_I2C_ADDR,MSP_SET_MATRIX, mspm);
3490
3269
		break;
3491
                      ivtv_call_i2c_client(itv,
3492
                                           ivtv_i2c_addresses[itv->card_type].msp34xx_addr,
3493
                                           MSP_SET_MATRIX, mspm);
3494
                      break;
3495
              case USE_GPIO:
3496
                      /* do nothing */
3497
                      break;
3498
              }
3270
	}
3499
	}
3271
	case IVTV_IOC_G_CODEC: {
3500
	case IVTV_IOC_G_CODEC: {
3272
		//FIXME copy_from_user needed
3501
		//FIXME copy_from_user needed
Lines 3293-3298 Link Here
3293
				sizeof(struct ivtv_ioctl_codec));
3522
				sizeof(struct ivtv_ioctl_codec));
3294
		}
3523
		}
3295
3524
3525
		if (itv->card_type == IVTV_M179)
3526
		{
3527
			ivtv_set_gpio_audiofreq(itv,codec->audio_bitmap & 0x03);
3528
		}
3529
3296
		/* VCD streamtype has some quirks. Handle them here */
3530
		/* VCD streamtype has some quirks. Handle them here */
3297
		if ((codec->stream_type == IVTV_STREAM_VCD) ||
3531
		if ((codec->stream_type == IVTV_STREAM_VCD) ||
3298
		    (codec->stream_type == IVTV_STREAM_MPEG1)) {
3532
		    (codec->stream_type == IVTV_STREAM_MPEG1)) {
Lines 3301-3320 Link Here
3301
			int tmpsize = 480;
3535
			int tmpsize = 480;
3302
3536
3303
			if (itv->v4l2.standard.active == 1) tmpsize = 576;
3537
			if (itv->v4l2.standard.active == 1) tmpsize = 576;
3304
			
3538
3305
			IVTV_DEBUG(IVTV_DEBUG_INFO,"ivtv ioctl: mpeg1_stream "
3539
			IVTV_DEBUG(IVTV_DEBUG_INFO,"ivtv ioctl: mpeg1_stream "
3306
					           "size %d\n", tmpsize);
3540
					           "size %d\n", tmpsize);
3307
3541
3308
			/* so far it looks like you can change width at will     *
3542
			/* so far it looks like you can change width at will     *
3309
		 	 * but the compressor is unhappy when the height changes *
3543
		 	 * but the compressor is unhappy when the height changes *
3310
			 * to anything other than 240 */
3544
			 * to anything other than 240 */
3311
		        wind.width = 352; 
3545
		        wind.width = 352;
3312
			wind.height = tmpsize;
3546
			wind.height = tmpsize;
3313
			vfmt->fmt.pix.width = 352;
3547
			vfmt->fmt.pix.width = 352;
3314
			vfmt->fmt.pix.height = tmpsize / 2;
3548
			vfmt->fmt.pix.height = tmpsize / 2;
3315
3549
3316
		        ivtv_call_i2c_client(itv,
3550
		        ivtv_call_i2c_client(itv,
3317
				IVTV_SAA7115_I2C_ADDR,DECODER_SET_SIZE,&wind);
3551
				ivtv_i2c_addresses[itv->card_type].saa7115_addr,
3552
				DECODER_SET_SIZE,&wind);
3318
		        memcpy (&itv->v4l2.streams[0].format,
3553
		        memcpy (&itv->v4l2.streams[0].format,
3319
				vfmt, sizeof(struct v4l2_format));
3554
				vfmt, sizeof(struct v4l2_format));
3320
		}
3555
		}
Lines 3348-3354 Link Here
3348
		put_user(ivtv_debug, dbg_level);
3583
		put_user(ivtv_debug, dbg_level);
3349
		break;
3584
		break;
3350
	}
3585
	}
3351
	case VIDIOC_STREAMOFF: { 
3586
	case VIDIOC_STREAMOFF: {
3352
		ivtv_v4l2_streamoff(id);
3587
		ivtv_v4l2_streamoff(id);
3353
		break;
3588
		break;
3354
	}
3589
	}
Lines 3362-3365 Link Here
3362
	}
3597
	}
3363
	return 0;
3598
	return 0;
3364
}
3599
}
3365
(-)ivtv/driver/ivtv-driver.c (-37 / +451 lines)
Lines 3-8 Link Here
3
 * Author: Kevin Thayer (nufan_wfk at yahoo.com)
3
 * Author: Kevin Thayer (nufan_wfk at yahoo.com)
4
 * License: GPL
4
 * License: GPL
5
 * http://www.sourceforge.net/projects/ivtv/
5
 * http://www.sourceforge.net/projects/ivtv/
6
 * 
7
 * -----
8
 * MPG600/MPG160 support by  T.Adachi <tadachi@tadachi-net.com>
9
 *                      and Takeru KOMORIYA<komoriya@paken.org>
10
 *
11
 * AVerMedia M179 GPIO info by Chris Pinkham <cpinkham@bc2va.org>
12
 *                using information provided by Jiun-Kuei Jung @ AVerMedia.
6
 */
13
 */
7
14
8
#include "ivtv.h"
15
#include "ivtv.h"
Lines 49-54 Link Here
49
		{0,}
56
		{0,}
50
};
57
};
51
58
59
/********************** card configuration *******************************/
60
/* card spec flags */
61
struct card_function_flag_st ivtv_card_flags[] = {
62
	{IVTV_250_V1, 1, USE_MSP34XX, HANDLE_VOL},
63
	{IVTV_250_V2, 0, USE_MSP34XX, HANDLE_VOL},
64
	{IVTV_250_V3, 1, USE_MSP34XX, HANDLE_VOL},
65
	{IVTV_250_V4, 0, USE_MSP34XX, HANDLE_VOL},
66
	{IVTV_350_V1, 1, USE_MSP34XX, HANDLE_VOL},
67
	{IVTV_350_V2, 1, USE_MSP34XX, HANDLE_VOL},
68
	{IVTV_MPG600, 0, USE_GPIO,    NOT_HANDLE_VOL},
69
	{IVTV_MPG160, 1, USE_GPIO,    NOT_HANDLE_VOL},
70
	{IVTV_M179,   1, USE_GPIO,    NOT_HANDLE_VOL}
71
};
72
73
/*
74
 * GPIO assignment of Yuan MPG600/MPG160
75
 *
76
 *    bit 15  14  13  12 |  11  10   9   8 |   7   6   5   4 |   3   2   1   0
77
 * OUTPUT         IN1 IN0                                       AM3 AM2 AM1 AM0
78
 *  INPUT                   DM1         DM0
79
 *
80
 *   IN* : Input selection
81
 *          IN1 IN0
82
 *           1   1  N/A
83
 *           1   0  Line
84
 *           0   1  N/A
85
 *           0   0  Tuner
86
 *
87
 *   AM* : Audio Mode
88
 *          AM3  0: Normal        1: Mixed(Sub+Main channel)
89
 *          AM2  0: Subchannel    1: Main channel
90
 *          AM1  0: Stereo        1: Mono
91
 *          AM0  0: Normal        1: Mute
92
 *
93
 *   DM* : Detected tuner audio Mode
94
 *          DM1  0: Stereo        1: Mono
95
 *          DM0  0: Multiplex     1: Normal
96
 *
97
 * GPIO Initial Settings
98
 *           MPG600   MPG160
99
 *     DIR   0x3080   0x7080
100
 *  OUTPUT   0x000C   0x400C
101
 *
102
 *  Special thanks to Makoto Iguchi <iguchi@tahoo.org> and Mr. Anonymous
103
 *  for analyzing GPIO of MPG160.
104
 *
105
 *****************************************************************************
106
 *
107
 * GPIO assignment of Avermedia M179 (per information direct from AVerMedia)
108
 *
109
 *    bit 15  14  13  12 |  11  10   9   8 |   7   6   5   4 |   3   2   1   0
110
 * OUTPUT IN0 AM0 IN1               AM1 AM2       IN2     BR0   BR1
111
 *  INPUT
112
 *
113
 *   IN* : Input selection
114
 *          IN0 IN1 IN2
115
 *           *   1   *  Mute
116
 *           0   0   0  Line-In
117
 *           1   0   0  TV Tuner Audio
118
 *           0   0   1  FM Audio
119
 *           1   0   1  Mute
120
 *
121
 *   AM* : Audio Mode
122
 *          AM0 AM1 AM2
123
 *           0   0   0  TV Tuner Audio: L_OUT=(L+R)/2, R_OUT=SAP
124
 *           0   0   1  TV Tuner Audio: L_OUT=R_OUT=SAP   (SAP)
125
 *           0   1   0  TV Tuner Audio: L_OUT=L, R_OUT=R   (stereo)
126
 *           0   1   1  TV Tuner Audio: mute
127
 *           1   *   *  TV Tuner Audio: L_OUT=R_OUT=(L+R)/2   (mono)
128
 *
129
 *   BR* : Audio Bitrate
130
 *          BR0 BR1
131
 *           0   0   32 kHz
132
 *           0   1   44.1 kHz
133
 *           1   0   48 kHz
134
 *
135
 *   DM* : Detected tuner audio Mode
136
 *         Unknown currently
137
 *
138
 * GPIO Initial Settings
139
 *           MPG600   MPG160
140
 *     DIR   0x3080   0x7080
141
 *  OUTPUT   0x000C   0x400C
142
 *
143
 * Special thanks to AVerMedia Technologies, Inc. and Jiun-Kuei Jung at
144
 * AVerMedia for providing the GPIO information used to add support
145
 * for the M179 cards.
146
 */
147
148
struct ivtv_gpio_data_st ivtv_gpio_data[] = {
149
	/* card_type,need_init,direction,out_init,
150
	 * input_mask,input_tuner,input_line,mute_mask,mute_mute,mute_unmute,
151
	 * audio_mask,audio_mono,audio_stereo,audio_main,audio_sub,audio_mixed,
152
	 * audio_freq_mask, audio_32000, audio_44100, audio_48000,
153
	 * tuner_mask,tuner_stereo,tuner_mono,tuner_multiples
154
	 */
155
	{IVTV_250_V1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
156
		0, 0, 0, 0, 0, 0},
157
	{IVTV_250_V2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158
		0, 0, 0, 0, 0, 0},
159
	{IVTV_250_V3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
160
		0, 0, 0, 0, 0, 0},
161
	{IVTV_250_V4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
162
		0, 0, 0, 0, 0, 0},
163
	{IVTV_350_V1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
164
		0, 0, 0, 0, 0, 0},
165
	{IVTV_350_V2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
166
		0, 0, 0, 0, 0, 0},
167
	{IVTV_MPG600, 1, 0x3080, 0x0004, /* Normal/main ch./Stereo */
168
	 0xcfff, 0x0000, 0x2000, 0xfffe, 0x0001, 0x0000,
169
	 0xfff1, 0x0006, 0x0004, 0x0004, 0x0000, 0x0008,
170
	 0xffff, 0x0000, 0x0000, 0x0000,
171
	 0xf6ff, 0x0100, 0x0900, 0x0100},
172
	{IVTV_MPG160, 1, 0x7080, 0x400c, /* Normal/main ch./Stereo */
173
	 0xcfff, 0x0000, 0x2000, 0xfffe, 0x0001, 0x0000,
174
	 0xfff1, 0x0006, 0x0004, 0x0004, 0x0000, 0x0008,
175
	 0xffff, 0x0000, 0x0000, 0x0000,
176
	 0xf6ff, 0x0100, 0x0900, 0x0100},
177
	{IVTV_M179, 1, 0xE380, 0x8290, /* Normal/main ch./Stereo, 48kHz */
178
	 ~0x8040, 0x8000, 0x0000, ~0x2000, 0x2000, 0x0000,
179
	 ~0x4300, 0x4000, 0x0200, 0x0200, 0x0100, 0x0000,
180
	 ~0x0018, 0x0000, 0x0008, 0x0010,
181
	 ~0x4000, 0x0000, 0x4000, 0x0000}
182
};
183
184
/* I2C addresses */
185
struct i2c_addresses_st ivtv_i2c_addresses[] = {
186
	{IVTV_250_V1, IVTV_TUNER_I2C_ADDR, IVTV_SAA7115_I2C_ADDR, IVTV_MSP3400_I2C_ADDR},
187
	{IVTV_250_V2, IVTV_TUNER_I2C_ADDR, IVTV_SAA7115_I2C_ADDR, IVTV_MSP3400_I2C_ADDR},
188
	{IVTV_250_V3, IVTV_TUNER_I2C_ADDR, IVTV_SAA7115_I2C_ADDR, IVTV_MSP3400_I2C_ADDR},
189
	{IVTV_250_V4, IVTV_TUNER_I2C_ADDR, IVTV_SAA7115_I2C_ADDR, IVTV_MSP3400_I2C_ADDR},
190
	{IVTV_350_V1, IVTV_TUNER_I2C_ADDR, IVTV_SAA7115_I2C_ADDR, IVTV_MSP3400_I2C_ADDR},
191
	{IVTV_350_V2, IVTV_TUNER_I2C_ADDR, IVTV_SAA7115_I2C_ADDR, IVTV_MSP3400_I2C_ADDR},
192
	{IVTV_MPG600, IVTV_MPG600_TUNER_I2C_ADDR, IVTV_SAA7115_I2C_ADDR, 0},
193
	{IVTV_MPG160, IVTV_MPG160_TUNER_I2C_ADDR, IVTV_SAA7115_I2C_ADDR, 0},
194
	{IVTV_M179,   IVTV_M179_TUNER_I2C_ADDR,   IVTV_SAA7115_I2C_ADDR, 0}
195
};
196
197
/* MSP34XX audio mapping */
198
struct ivtv_msp34xx_audio_map_st ivtv_msp34xx_audio_map[] = {
199
	{IVTV_250_V1, 3, 1},
200
	{IVTV_250_V2, 3, 1},
201
	{IVTV_250_V3, 3, 1},
202
	{IVTV_250_V4, 3, 1},
203
	{IVTV_350_V1, 3, 1},
204
	{IVTV_350_V2, 3, 1},
205
	{IVTV_MPG600, 0, 0},
206
	{IVTV_MPG160, 0, 0},
207
	{IVTV_M179,   0, 0}
208
};
209
210
struct ivtv_card_params_st ivtv_card_params[] = {
211
	/* card_type, subsystem id, capabilities, stream, card name, chip name */
212
	{IVTV_250_V1, IVTV_PCI_ID_250_V1,
213
	 (V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_TUNER|
214
	  V4L2_CAP_AUDIO|V4L2_CAP_READWRITE),
215
	 IVTV_250_V1_STREAMS,
216
	 "wintv pvr 250rev1",
217
	 "iTVC15"},
218
219
	{IVTV_250_V2, IVTV_PCI_ID_250_V2,
220
	 (V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_TUNER|
221
	  V4L2_CAP_AUDIO|V4L2_CAP_READWRITE),
222
	 IVTV_250_V2_STREAMS,
223
	 "wintv pvr 250rev2",
224
	 "iTVC16"},
225
226
	{IVTV_250_V3, IVTV_PCI_ID_250_V3,
227
	 (V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_TUNER|
228
	  V4L2_CAP_AUDIO|V4L2_CAP_READWRITE),
229
	 IVTV_250_V3_STREAMS,
230
	 "wintv pvr 250rev3",
231
	 "iTVC15"},
232
233
	{IVTV_250_V4, IVTV_PCI_ID_250_V4,
234
	 (V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_TUNER|
235
	  V4L2_CAP_AUDIO|V4L2_CAP_READWRITE),
236
	 IVTV_250_V4_STREAMS,
237
	 "wintv pvr 250rev4",
238
	 "iTVC16"},
239
240
	{IVTV_350_V1, IVTV_PCI_ID_350_V1,
241
	 (V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_TUNER|
242
	  V4L2_CAP_AUDIO|V4L2_CAP_READWRITE|
243
	  V4L2_CAP_VIDEO_OUTPUT),
244
	 IVTV_350_V1_STREAMS,
245
	 "wintv pvr 350rev1",
246
	 "iTVC15"},
247
248
	{IVTV_350_V2, IVTV_PCI_ID_350_V2,
249
	 (V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_TUNER|
250
	  V4L2_CAP_AUDIO|V4L2_CAP_READWRITE|
251
	  V4L2_CAP_VIDEO_OUTPUT),
252
	 IVTV_350_V2_STREAMS,
253
	 "wintv pvr 350rev2",
254
	 "iTVC15"},
255
256
	{IVTV_MPG600, IVTV_PCI_ID_MPG600,
257
	 (V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_TUNER|
258
	  V4L2_CAP_AUDIO|V4L2_CAP_READWRITE),
259
	 IVTV_MPG600_STREAMS,
260
	 "YUAN MPG600/Kuroutoshikou ITVC16-STVLP",
261
	 "iTVC16"},
262
263
	{IVTV_MPG160, IVTV_PCI_ID_MPG160,
264
	 (V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_TUNER|
265
	  V4L2_CAP_AUDIO|V4L2_CAP_READWRITE),
266
	 IVTV_MPG160_STREAMS,
267
	 "YUAN MPG160/Kuroutoshikou ITVC15-STVLP",
268
	 "iTVC15"},
269
270
	{IVTV_M179, IVTV_PCI_ID_M179,
271
	 (V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_TUNER|
272
	  V4L2_CAP_AUDIO|V4L2_CAP_READWRITE),
273
	 IVTV_M179_STREAMS,
274
	 "AverMedia M179",
275
	 "iTVC15"},
276
277
	{-1,0,0,0,NULL}
278
};
279
/********************** end of card configuration ************************/
280
52
static void ivtv_irq_dec_vsync(struct ivtv* itv);
281
static void ivtv_irq_dec_vsync(struct ivtv* itv);
53
static IRQRETURN_T ivtv_irq_handler(int irq, void *dev_id, struct pt_regs *regs);
282
static IRQRETURN_T ivtv_irq_handler(int irq, void *dev_id, struct pt_regs *regs);
54
static void ivtv_DMA_done(struct ivtv *itv);
283
static void ivtv_DMA_done(struct ivtv *itv);
Lines 79-85 Link Here
79
/* low debugging by default */
308
/* low debugging by default */
80
#if 0
309
#if 0
81
int debug = ( 	IVTV_DEBUG_ERR | IVTV_DEBUG_INFO  | IVTV_DEBUG_API
310
int debug = ( 	IVTV_DEBUG_ERR | IVTV_DEBUG_INFO  | IVTV_DEBUG_API
82
		| IVTV_DEBUG_DMA | IVTV_DEBUG_IOCTL | IVTV_DEBUG_I2C 
311
		| IVTV_DEBUG_DMA | IVTV_DEBUG_IOCTL | IVTV_DEBUG_I2C
83
		| IVTV_DEBUG_IRQ );
312
		| IVTV_DEBUG_IRQ );
84
#endif
313
#endif
85
int ivtv_debug = IVTV_DEBUG_ERR;
314
int ivtv_debug = IVTV_DEBUG_ERR;
Lines 497-503 Link Here
497
	}
726
	}
498
727
499
728
500
	if (itv->card_type != IVTV_250_V2) {
729
	if (ivtv_card_flags[itv->card_type].ivtv15) {
501
                IVTV_DEBUG(IVTV_DEBUG_INFO, "Loading decoder firmware\n");
730
                IVTV_DEBUG(IVTV_DEBUG_INFO, "Loading decoder firmware\n");
502
                if (load_fw_direct(IVTV_FIRM_DEC_FILENAME,
731
                if (load_fw_direct(IVTV_FIRM_DEC_FILENAME,
503
				   (char *)(itv->io_mem + IVTV_DEC_MEM_START)) !=
732
				   (char *)(itv->io_mem + IVTV_DEC_MEM_START)) !=
Lines 540-546 Link Here
540
	ivtv_sleep_timeout(HZ/100);
769
	ivtv_sleep_timeout(HZ/100);
541
	
770
	
542
	/*halt dec firmware */
771
	/*halt dec firmware */
543
	if (IVTV_250_V2 != itv->card_type) {
772
	if (ivtv_card_flags[itv->card_type].ivtv15) {
544
        	x = ivtv_api(itv->dec_mbox, &itv->dec_msem, IVTV_API_DEC_HALT_FW,
773
        	x = ivtv_api(itv->dec_mbox, &itv->dec_msem, IVTV_API_DEC_HALT_FW,
545
			&result, 0, &data[0]);
774
			&result, 0, &data[0]);
546
		if (x) IVTV_DEBUG(IVTV_DEBUG_ERR, "stop_fw error 4. Code %d\n",x);
775
		if (x) IVTV_DEBUG(IVTV_DEBUG_ERR, "stop_fw error 4. Code %d\n",x);
Lines 576-582 Link Here
576
	writel(IVTV_CMD_APU_PING, (IVTV_REG_APU + itv->reg_mem));
805
	writel(IVTV_CMD_APU_PING, (IVTV_REG_APU + itv->reg_mem));
577
806
578
	IVTV_DEBUG(IVTV_DEBUG_INFO, "Stopping VPU\n");
807
	IVTV_DEBUG(IVTV_DEBUG_INFO, "Stopping VPU\n");
579
	if (IVTV_250_V2 == itv->card_type) {
808
	if (!ivtv_card_flags[itv->card_type].ivtv15) {
580
		writel(IVTV_CMD_VPU_STOP16, (IVTV_REG_VPU + itv->reg_mem));
809
		writel(IVTV_CMD_VPU_STOP16, (IVTV_REG_VPU + itv->reg_mem));
581
	}
810
	}
582
	else {
811
	else {
Lines 626-632 Link Here
626
	ivtv_sleep_timeout(HZ);
855
	ivtv_sleep_timeout(HZ);
627
	
856
	
628
	/*I guess this is read-modify-write :)*/
857
	/*I guess this is read-modify-write :)*/
629
	if (IVTV_250_V2 == itv->card_type) {
858
	if (!ivtv_card_flags[itv->card_type].ivtv15) {
630
		writel((readl(itv->reg_mem + IVTV_REG_VPU)&IVTV_MASK_VPU_ENABLE16),
859
		writel((readl(itv->reg_mem + IVTV_REG_VPU)&IVTV_MASK_VPU_ENABLE16),
631
			(IVTV_REG_VPU+itv->reg_mem));
860
			(IVTV_REG_VPU+itv->reg_mem));
632
	}
861
	}
Lines 638-643 Link Here
638
	IVTV_DEBUG(IVTV_DEBUG_INFO, "Sleeping for 1 sec\n");
867
	IVTV_DEBUG(IVTV_DEBUG_INFO, "Sleeping for 1 sec\n");
639
	ivtv_sleep_timeout(HZ);
868
	ivtv_sleep_timeout(HZ);
640
869
870
	/* GPIO init */
871
	if (ivtv_gpio_data[itv->card_type].need_init) {
872
		IVTV_DEBUG(IVTV_DEBUG_INFO, "GPIO INIT\n");
873
		ivtv_set_gpio_audio(itv,IVTV_GPIO_AUDIO_INIT);
874
	}
875
641
	/* FIXME Send Status API commands to encoder and decoder to verify!*/
876
	/* FIXME Send Status API commands to encoder and decoder to verify!*/
642
877
643
	return 0;
878
	return 0;
Lines 898-904 Link Here
898
		default:
1133
		default:
899
			if (down_interruptible(sem)) return -ERESTARTSYS;
1134
			if (down_interruptible(sem)) return -ERESTARTSYS;
900
			gotsem	= 1;
1135
			gotsem	= 1;
901
			break;		
1136
			break;
902
	}
1137
	}
903
1138
904
	/* wait 200ms for mailbox to become free */
1139
	/* wait 200ms for mailbox to become free */
Lines 913-926 Link Here
913
        if (x == -EBUSY) {
1148
        if (x == -EBUSY) {
914
		/* dilemma here:
1149
		/* dilemma here:
915
		 if the command that currently has the mailbox
1150
		 if the command that currently has the mailbox
916
		 is lost, then it'll never free up the box, and 
1151
		 is lost, then it'll never free up the box, and
917
		 we'll lose our only 'general purpose' box forever.
1152
		 we'll lose our only 'general purpose' box forever.
918
		 But if it comes back, we run the risk of squishing
1153
		 But if it comes back, we run the risk of squishing
919
		 something important!. */
1154
		 something important!. */
920
		switch (local_box->cmd) {
1155
		switch (local_box->cmd) {
921
		case IVTV_API_DEC_DMA_FROM_HOST:
1156
		case IVTV_API_DEC_DMA_FROM_HOST:
922
			/* if we got here, it's because the call to xfer the dma 
1157
			/* if we got here, it's because the call to xfer the dma
923
			   was finished, and the command that wants to run has 
1158
			   was finished, and the command that wants to run has
924
			   already slept for 20ms. It's probably safe to take over
1159
			   already slept for 20ms. It's probably safe to take over
925
			*/
1160
			*/
926
                	IVTV_DEBUG(IVTV_DEBUG_API, "Forcibly freeing mailbox\n");
1161
                	IVTV_DEBUG(IVTV_DEBUG_API, "Forcibly freeing mailbox\n");
Lines 975-982 Link Here
975
			   "Encoder revision: 0x%08x\n", data[0]);
1210
			   "Encoder revision: 0x%08x\n", data[0]);
976
	}
1211
	}
977
1212
978
	if (itv->card_type != IVTV_250_V2) {
1213
	if (ivtv_card_flags[itv->card_type].ivtv15) {
979
		/* Decoder */	
1214
		/* Decoder */
980
		IVTV_DEBUG(IVTV_DEBUG_INFO, "Getting decoder firmware rev.\n");
1215
		IVTV_DEBUG(IVTV_DEBUG_INFO, "Getting decoder firmware rev.\n");
981
		x = ivtv_api(itv->dec_mbox, &itv->dec_msem, IVTV_API_DEC_GETVER,
1216
		x = ivtv_api(itv->dec_mbox, &itv->dec_msem, IVTV_API_DEC_GETVER,
982
			&result, 0, &data[0]);
1217
			&result, 0, &data[0]);
Lines 989-995 Link Here
989
				   "Decoder revision: 0x%08x\n", data[0]);
1224
				   "Decoder revision: 0x%08x\n", data[0]);
990
		}
1225
		}
991
	}
1226
	}
992
	
1227
993
	return 0;
1228
	return 0;
994
}
1229
}
995
1230
Lines 1290-1296 Link Here
1290
	struct ivtv *itv=(struct ivtv *)dev_id;
1525
	struct ivtv *itv=(struct ivtv *)dev_id;
1291
1526
1292
	spin_lock(&itv->lock);
1527
	spin_lock(&itv->lock);
1293
	
1528
1294
	/* get contents of irq status register*/
1529
	/* get contents of irq status register*/
1295
	stat = readl(itv->reg_mem + IVTV_REG_IRQSTATUS);
1530
	stat = readl(itv->reg_mem + IVTV_REG_IRQSTATUS);
1296
1531
Lines 1743-1749 Link Here
1743
1978
1744
/* FIXME this function does way more than it should */
1979
/* FIXME this function does way more than it should */
1745
static int __devinit ivtv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id) {
1980
static int __devinit ivtv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id) {
1746
	int retval=0;
1981
	int i, retval=0;
1747
	unsigned char pci_latency;
1982
	unsigned char pci_latency;
1748
	struct ivtv *itv;
1983
	struct ivtv *itv;
1749
	struct video_channel v;
1984
	struct video_channel v;
Lines 1788-1813 Link Here
1788
	/* Set FrameBuffer-ID to invalid */
2023
	/* Set FrameBuffer-ID to invalid */
1789
	itv->fb_id = -1;
2024
	itv->fb_id = -1;
1790
2025
1791
	switch (dev->subsystem_device) {
2026
	i=0;
1792
	case IVTV_PCI_ID_250_V2:
2027
	do {
1793
	case IVTV_PCI_ID_250_V4:
2028
		if (dev->subsystem_device == ivtv_card_params[i].subsystem_id) break;
1794
		IVTV_DEBUG(IVTV_DEBUG_ERR, "Found an iTVC16 based chip\n");
2029
		i++;
1795
		itv->card_type = IVTV_250_V2;
2030
	} while(ivtv_card_params[i].card_type != -1);
1796
		break;
2031
1797
	case IVTV_PCI_ID_350_V1:
2032
	if (ivtv_card_params[i].card_type != -1) {
1798
	case IVTV_PCI_ID_350_V2:
2033
		itv->card_type = ivtv_card_params[i].card_type;
1799
		IVTV_DEBUG(IVTV_DEBUG_ERR, "Found an iTVC15 based chip\n");
2034
		IVTV_DEBUG(IVTV_DEBUG_ERR, "Found an %s based chip\n",ivtv_card_params[i].chip);
1800
		itv->card_type = IVTV_350_V1;
2035
	} else {
1801
		break;
2036
		IVTV_DEBUG(IVTV_DEBUG_INFO, "subsystem_id is %x\n",dev->subsystem_device);
1802
	case IVTV_PCI_ID_250_V1:
1803
	case IVTV_PCI_ID_250_V3:
1804
		IVTV_DEBUG(IVTV_DEBUG_ERR, "Found an iTVC15 based chip\n");
1805
		itv->card_type = IVTV_250_V1;
2037
		itv->card_type = IVTV_250_V1;
1806
		break;
1807
	default: /* Default to 250 v1 style */
1808
		IVTV_DEBUG(IVTV_DEBUG_ERR, "Found an unknown chip, treating it like an iTVC15\n");
2038
		IVTV_DEBUG(IVTV_DEBUG_ERR, "Found an unknown chip, treating it like an iTVC15\n");
1809
		itv->card_type = IVTV_250_V1;
1810
		break;
1811
	}
2039
	}
1812
2040
1813
	init_MUTEX(&itv->enc_msem);
2041
	init_MUTEX(&itv->enc_msem);
Lines 1869-1874 Link Here
1869
	pci_read_config_byte(dev, PCI_CLASS_REVISION, &itv->card_rev);
2097
	pci_read_config_byte(dev, PCI_CLASS_REVISION, &itv->card_rev);
1870
	pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency);
2098
	pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency);
1871
2099
2100
	if (pci_latency < 64) {
2101
		IVTV_DEBUG(IVTV_DEBUG_ERR, "Unreasonably low latency timer, "
2102
			"setting to 64 (was %d)\n",
2103
			pci_latency);
2104
		pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
2105
		pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency);
2106
	}
2107
1872
	IVTV_DEBUG(IVTV_DEBUG_INFO, "%d (rev %d) at %02x:%02x.%x, ",
2108
	IVTV_DEBUG(IVTV_DEBUG_INFO, "%d (rev %d) at %02x:%02x.%x, ",
1873
		itv->dev->device, itv->card_rev, dev->bus->number,
2109
		itv->dev->device, itv->card_rev, dev->bus->number,
1874
		PCI_SLOT(dev->devfn),PCI_FUNC(dev->devfn));
2110
		PCI_SLOT(dev->devfn),PCI_FUNC(dev->devfn));
Lines 1967-1976 Link Here
1967
           SGarray_size),
2203
           SGarray_size),
1968
					PCI_DMA_TODEVICE);
2204
					PCI_DMA_TODEVICE);
1969
2205
1970
	if (itv->card_type == IVTV_350_V1) {
2206
	if (itv->card_type == IVTV_350_V1 || itv->card_type == IVTV_350_V2) {
1971
		/* decoder */
2207
		/* decoder */
1972
		itv->DSGarray = (struct ivtv_SG_element *)
2208
		itv->DSGarray = (struct ivtv_SG_element *)
1973
				 kmalloc(sizeof(struct ivtv_SG_element) * 
2209
				 kmalloc(sizeof(struct ivtv_SG_element) *
1974
				 DSGarray_size, GFP_KERNEL);
2210
				 DSGarray_size, GFP_KERNEL);
1975
		if (!(itv->DSGarray)) {
2211
		if (!(itv->DSGarray)) {
1976
			IVTV_DEBUG(IVTV_DEBUG_ERR, "Error allocating DSGarray[].\n");
2212
			IVTV_DEBUG(IVTV_DEBUG_ERR, "Error allocating DSGarray[].\n");
Lines 2000-2011 Link Here
2000
	else
2236
	else
2001
		v.norm = VIDEO_MODE_PAL;
2237
		v.norm = VIDEO_MODE_PAL;
2002
2238
2003
	ivtv_call_i2c_client(itv,IVTV_TUNER_I2C_ADDR, VIDIOCSCHAN,&v);
2239
	ivtv_call_i2c_client(itv,ivtv_i2c_addresses[itv->card_type].tuner_addr,
2240
			VIDIOCSCHAN,&v);
2004
2241
2005
	if (!ivtv_pal) {
2242
	if (!ivtv_pal) {
2006
		/* set the channel */
2243
		/* set the channel */
2007
		freq = 1076; /* ch. 4 67250*16/1000 */
2244
		freq = 1076; /* ch. 4 67250*16/1000 */
2008
		ivtv_call_i2c_client(itv,IVTV_TUNER_I2C_ADDR,VIDIOCSFREQ,&freq);
2245
		ivtv_call_i2c_client(itv,
2246
			ivtv_i2c_addresses[itv->card_type].tuner_addr,
2247
			VIDIOCSFREQ,&freq);
2009
	}
2248
	}
2010
2249
2011
	retval = ivtv_v4l2_setup(itv);
2250
	retval = ivtv_v4l2_setup(itv);
Lines 2318-2324 Link Here
2318
	/* Skip the first 4 bytes of mpg streams to help out
2557
	/* Skip the first 4 bytes of mpg streams to help out
2319
	 * finicky decoders.. but not for iTVC16 */
2558
	 * finicky decoders.. but not for iTVC16 */
2320
	if ((id->type == 0) && (itv->first_read == 1) &&
2559
	if ((id->type == 0) && (itv->first_read == 1) &&
2321
	    (itv->card_type != IVTV_250_V2)) {
2560
	    (ivtv_card_flags[itv->card_type].ivtv15)) {
2322
		for( x = 0; x < buf->buffer.bytesused-4; x++ ) {
2561
		for( x = 0; x < buf->buffer.bytesused-4; x++ ) {
2323
			unsigned char *p;
2562
			unsigned char *p;
2324
			itv->first_read = 0;
2563
			itv->first_read = 0;
Lines 2943-2948 Link Here
2943
	return ret;
3182
	return ret;
2944
}
3183
}
2945
3184
3185
/********************* GPIO stuffs *********************/
3186
3187
void ivtv_gpio_write(unsigned char *gpio_addr, u32 data)
3188
{
3189
	writel(data,(u32)gpio_addr);
3190
}
3191
3192
u32 ivtv_gpio_read(unsigned char *gpio_addr)
3193
{
3194
	return readl((u32)gpio_addr);
3195
}
3196
3197
void ivtv_chg_gpio(unsigned char *address, u32 mask, u32 write_data)
3198
{
3199
	ivtv_gpio_write(address,(readl(address) & mask)|write_data);
3200
}
3201
3202
u32 ivtv_chk_gpio(unsigned char *address, u32 mask)
3203
{
3204
	return (ivtv_gpio_read(address) & (mask ^ 0xffff));
3205
}
3206
3207
/* audio control by GPIO */
3208
void ivtv_set_gpio_audio(struct ivtv *itv, int command)
3209
{
3210
	struct ivtv_gpio_data_st gpio_data = ivtv_gpio_data[itv->card_type];
3211
3212
	switch (command) {
3213
	case IVTV_GPIO_AUDIO_INIT:
3214
		IVTV_DEBUG(IVTV_DEBUG_INFO,
3215
			   "GPIO initial dir:%08x, out:%08x\n",
3216
			   ivtv_gpio_read(itv->reg_mem+IVTV_GPIO_DIREC_ADDR),
3217
			   ivtv_gpio_read(itv->reg_mem+IVTV_GPIO_OUT_ADDR));
3218
		/* init output data then direction */
3219
		ivtv_gpio_write(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3220
				gpio_data.out_init);
3221
		ivtv_gpio_write(itv->reg_mem+IVTV_GPIO_DIREC_ADDR,
3222
				gpio_data.direction);
3223
		break;
3224
	case IVTV_GPIO_AUDIO_TUNER:
3225
		ivtv_chg_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3226
			      gpio_data.input_mask,gpio_data.input_tuner);
3227
		break;
3228
	case IVTV_GPIO_AUDIO_LINE:
3229
		ivtv_chg_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3230
			      gpio_data.input_mask,gpio_data.input_line);
3231
		break;
3232
	case IVTV_GPIO_AUDIO_MUTE:
3233
		ivtv_chg_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3234
			      gpio_data.mute_mask,gpio_data.mute_mute);
3235
		break;
3236
	case IVTV_GPIO_AUDIO_UNMUTE:
3237
		ivtv_chg_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3238
			      gpio_data.mute_mask,gpio_data.mute_unmute);
3239
		break;
3240
	}
3241
}
3242
3243
int ivtv_get_gpio_audio(struct ivtv *itv, int command)
3244
{
3245
	struct ivtv_gpio_data_st gpio_data = ivtv_gpio_data[itv->card_type];
3246
	int out, data;
3247
3248
	out = 0;
3249
	data = -1;   /* 'data' must be different from 'out' here */
3250
	
3251
	switch (command) {
3252
	case IVTV_GPIO_AUDIO_INIT:
3253
		/* do nothing*/
3254
		break;
3255
	case IVTV_GPIO_AUDIO_TUNER:
3256
		out = ivtv_chk_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3257
				    gpio_data.input_mask);
3258
		data = gpio_data.input_tuner;
3259
		break;
3260
	case IVTV_GPIO_AUDIO_LINE:
3261
	       out = ivtv_chk_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3262
				   gpio_data.input_mask);
3263
	       data = gpio_data.input_line;
3264
	       break;
3265
	case IVTV_GPIO_AUDIO_MUTE:
3266
		out = ivtv_chk_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3267
				    gpio_data.mute_mask);
3268
		data = gpio_data.mute_mute;
3269
		break;
3270
	case IVTV_GPIO_AUDIO_UNMUTE:
3271
		out = ivtv_chk_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3272
				    gpio_data.mute_mask);
3273
		data = gpio_data.mute_unmute;
3274
		break;
3275
	}
3276
3277
	if (out == data)
3278
		return 1;
3279
3280
	return 0;
3281
}
3282
3283
/* set MPG600/MPG160/M179 tuner audio freq */
3284
void ivtv_set_gpio_audiofreq(struct ivtv *itv,int audio_freq)
3285
{
3286
	struct ivtv_gpio_data_st gpio_data = ivtv_gpio_data[itv->card_type];
3287
3288
	switch (audio_freq) {
3289
	case IVTV_AUDIO_32000:
3290
		ivtv_chg_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3291
			      gpio_data.audio_freq_mask,gpio_data.audio_32000);
3292
		break;
3293
	case IVTV_AUDIO_44100:
3294
		ivtv_chg_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3295
			      gpio_data.audio_freq_mask,gpio_data.audio_44100);
3296
		break;
3297
	case IVTV_AUDIO_48000:
3298
		ivtv_chg_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3299
			      gpio_data.audio_freq_mask,gpio_data.audio_48000);
3300
		break;
3301
	}
3302
}
3303
3304
/* set MPG600/MPG160/M179 tuner audio mode */
3305
void ivtv_set_gpio_audiomode(struct ivtv *itv,int audio_mode)
3306
{
3307
	struct ivtv_gpio_data_st gpio_data = ivtv_gpio_data[itv->card_type];
3308
	u32 gpio_dir, gpio_out, gpio_in;
3309
	
3310
	switch (audio_mode) {
3311
	case V4L2_TUNER_MODE_MONO:
3312
		ivtv_chg_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3313
			      gpio_data.audio_mask,gpio_data.audio_mono);
3314
		break;
3315
	case V4L2_TUNER_MODE_STEREO:
3316
		ivtv_chg_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3317
			      gpio_data.audio_mask,gpio_data.audio_stereo);
3318
		break;
3319
	case V4L2_TUNER_MODE_LANG1:
3320
		ivtv_chg_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3321
			      gpio_data.audio_mask,gpio_data.audio_main);
3322
		break;
3323
	case V4L2_TUNER_MODE_LANG2:
3324
		ivtv_chg_gpio(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3325
			      gpio_data.audio_mask,gpio_data.audio_sub);
3326
		break;
3327
	}
3328
3329
	/* GPIO debug interface */
3330
	if ((audio_mode & 0x10000) != 0) {
3331
		ivtv_gpio_write(itv->reg_mem+IVTV_GPIO_OUT_ADDR,
3332
				(u32)(audio_mode & 0xffff));
3333
		gpio_dir = ivtv_gpio_read(itv->reg_mem+IVTV_GPIO_DIREC_ADDR);
3334
		gpio_out = ivtv_gpio_read(itv->reg_mem+IVTV_GPIO_OUT_ADDR);
3335
		gpio_in = ivtv_gpio_read(itv->reg_mem+IVTV_GPIO_IN_ADDR);
3336
3337
		IVTV_DEBUG(IVTV_DEBUG_INFO,
3338
			   "GPIO status: DIR=0x%04x OUT=0x%04x IN=0x%04x\n",
3339
			   gpio_dir, gpio_out, gpio_in);
3340
	}
3341
}
3342
3343
/* get MPG600/MPG160/M179 tuner audio mode */
3344
int ivtv_get_gpio_audiomode(struct ivtv *itv)
3345
{
3346
	struct ivtv_gpio_data_st gpio_data = ivtv_gpio_data[itv->card_type];
3347
	u32 st;
3348
3349
	st = ivtv_chk_gpio(itv->reg_mem+IVTV_GPIO_IN_ADDR,
3350
			   gpio_data.tuner_mask);
3351
3352
	if (st == gpio_data.tuner_multiplex)
3353
		return 2;
3354
	else if (st == gpio_data.tuner_stereo)
3355
		return 1;
3356
	return 0; /* mono */
3357
}
3358
3359
2946
static int module_start(void)  {
3360
static int module_start(void)  {
2947
	int loop_a;
3361
	int loop_a;
2948
	int i;
3362
	int i;
(-)ivtv/driver/ivtv.h (-1 / +123 lines)
Lines 6-11 Link Here
6
 * Author: Kevin Thayer (nufan_wfk at yahoo.com)
6
 * Author: Kevin Thayer (nufan_wfk at yahoo.com)
7
 * License: GPL
7
 * License: GPL
8
 * http://www.sourceforge.net/projects/ivtv/
8
 * http://www.sourceforge.net/projects/ivtv/
9
 * 
10
 * -----
11
 * MPG600/MPG160 support by  T.Adachi <tadachi@tadachi-net.com>
12
 *                      and Takeru KOMORIYA<komoriya@paken.org>
13
 *
14
 * AVerMedia M179 GPIO info by Chris Pinkham <cpinkham@bc2va.org>
15
 *                using information provided by Jiun-Kuei Jung @ AVerMedia.
9
 */
16
 */
10
#ifndef MODULE
17
#ifndef MODULE
11
 #define MODULE
18
 #define MODULE
Lines 104-115 Link Here
104
#define IVTV_PCI_ID_250_V4 0x4803 /* treat like 250_V2 */
111
#define IVTV_PCI_ID_250_V4 0x4803 /* treat like 250_V2 */
105
#define IVTV_PCI_ID_350_V1 0x4000
112
#define IVTV_PCI_ID_350_V1 0x4000
106
#define IVTV_PCI_ID_350_V2 0x4800 /* treat like 350_V1 */
113
#define IVTV_PCI_ID_350_V2 0x4800 /* treat like 350_V1 */
114
#define IVTV_PCI_ID_MPG600 0xfff3
115
#define IVTV_PCI_ID_MPG160 0x0000
116
#define IVTV_PCI_ID_M179   0xa3cf
107
#define IVTV_250_V1 0 /* wintv pvr 250, encoder and decoder */
117
#define IVTV_250_V1 0 /* wintv pvr 250, encoder and decoder */
108
#define IVTV_250_V2 1 /* pvr 250, encoder only */
118
#define IVTV_250_V2 1 /* pvr 250, encoder only */
109
#define IVTV_350_V1 2 /* encoder, decoder, tv-out */
119
#define IVTV_250_V3 2 /* wintv pvr 250, encoder and decoder */
120
#define IVTV_250_V4 3 /* pvr 250, encoder only */
121
#define IVTV_350_V1 4 /* encoder, decoder, tv-out */
122
#define IVTV_350_V2 5 /* encoder, decoder, tv-out */
123
#define IVTV_MPG600 6 /* Kuroutoshikou ITVC16-STVLP/YUAN MPG600, encoder only */
124
#define IVTV_MPG160 7 /* Kuroutoshikou ITVC15-STVLP/YUAN MPG160
125
                         iTVC15 based, but does not have tv-out */
126
#define IVTV_M179   8 /* AVerMedia M179 (encoder only) */
127
128
/* #define IVTV_350_V1 2 /* encoder, decoder, tv-out */
110
#define IVTV_250_V1_STREAMS 4
129
#define IVTV_250_V1_STREAMS 4
111
#define IVTV_250_V2_STREAMS 4
130
#define IVTV_250_V2_STREAMS 4
131
#define IVTV_250_V3_STREAMS 4
132
#define IVTV_250_V4_STREAMS 4
112
#define IVTV_350_V1_STREAMS 8
133
#define IVTV_350_V1_STREAMS 8
134
#define IVTV_350_V2_STREAMS 8
135
#define IVTV_MPG600_STREAMS 3
136
#define IVTV_MPG160_STREAMS 3
137
#define IVTV_M179_STREAMS   3
138
139
#define NO_AUDIO    0  /* the card can't handle audio */
140
#define USE_MSP34XX 1  /* switch audio by MSP34XX */
141
#define USE_GPIO    2  /* switch audio by GPIO */
142
143
#define IVTV_AUDIO_32000 0x2  /* 32 kHz audio */
144
#define IVTV_AUDIO_44100 0x0  /* 44.1 kHz audio */
145
#define IVTV_AUDIO_48000 0x1  /* 48 kHz audio */
146
113
#define IVTV_V4L2_DEC_OFFSET 16 /* offset from 0 to register dec. v4l2 minors on */
147
#define IVTV_V4L2_DEC_OFFSET 16 /* offset from 0 to register dec. v4l2 minors on */
114
#define IVTV_V4L2_PCM_OFFSET 24 /* offset from 0 to register pcm v4l2 minors on */
148
#define IVTV_V4L2_PCM_OFFSET 24 /* offset from 0 to register pcm v4l2 minors on */
115
#define IVTV_V4L2_YUV_OFFSET 32 /* offset from 0 to register yuv v4l2 minors on */
149
#define IVTV_V4L2_YUV_OFFSET 32 /* offset from 0 to register yuv v4l2 minors on */
Lines 139-145 Link Here
139
#define IVTV_MBOX_SIZE 80
173
#define IVTV_MBOX_SIZE 80
140
#define IVTV_SAA7115_I2C_ADDR 0x21
174
#define IVTV_SAA7115_I2C_ADDR 0x21
141
#define IVTV_TUNER_I2C_ADDR 0x61
175
#define IVTV_TUNER_I2C_ADDR 0x61
176
#define IVTV_MPG600_TUNER_I2C_ADDR 0x60
177
#define IVTV_MPG160_TUNER_I2C_ADDR 0x60
178
#define IVTV_M179_TUNER_I2C_ADDR 0x60
142
#define IVTV_MSP3400_I2C_ADDR 0x40
179
#define IVTV_MSP3400_I2C_ADDR 0x40
180
#define IVTV_GPIO_IN_ADDR    0x9008
181
#define IVTV_GPIO_OUT_ADDR   0x900c
182
#define IVTV_GPIO_DIREC_ADDR 0x9020
143
#define IVTV_DMA_BUF_SIZE 34560 /* 0x8000 = 32kbytes, 0x20000 = 128kbytes */
183
#define IVTV_DMA_BUF_SIZE 34560 /* 0x8000 = 32kbytes, 0x20000 = 128kbytes */
144
#define IVTV_DMA_DEC_BUF_SIZE 32768 /* 0x8000 = 32kbytes, 0x20000 = 128kbytes */
184
#define IVTV_DMA_DEC_BUF_SIZE 32768 /* 0x8000 = 32kbytes, 0x20000 = 128kbytes */
145
//#define IVTV_DMA_BUF_SIZE 65536 /* 0x8000 = 32kbytes, 0x20000 = 128kbytes */
185
//#define IVTV_DMA_BUF_SIZE 65536 /* 0x8000 = 32kbytes, 0x20000 = 128kbytes */
Lines 549-554 Link Here
549
589
550
#define IVTV_V4L2_DEC_MENUCOUNT 7
590
#define IVTV_V4L2_DEC_MENUCOUNT 7
551
591
592
/* MPG600/MPG160/M179 audio stuff */
593
#define IVTV_GPIO_AUDIO_INIT    0
594
#define IVTV_GPIO_AUDIO_TUNER   1
595
#define IVTV_GPIO_AUDIO_LINE    2
596
#define IVTV_GPIO_AUDIO_MUTE    3
597
#define IVTV_GPIO_AUDIO_UNMUTE  4
598
599
#define NOT_HANDLE_VOL 0
600
#define HANDLE_VOL     1
601
552
#ifdef SAA7115_REGTEST
602
#ifdef SAA7115_REGTEST
553
/* allow direct access to the saa7115 registers for testing */
603
/* allow direct access to the saa7115 registers for testing */
554
#define SAA7115_GET_REG         0xFFEE7705
604
#define SAA7115_GET_REG         0xFFEE7705
Lines 857-862 Link Here
857
	struct list_head	client_list;
907
	struct list_head	client_list;
858
};
908
};
859
909
910
/* for flag/value of each cards */
911
struct card_function_flag_st {
912
	int card_type;      /* card_type no */
913
	int ivtv15;         /* ivtv15:1 ivtv16:0 */
914
	int audio_selector; /* audio selector */
915
	int vol_control;    /* 1: the card can handle volume 0:not */
916
};
917
918
/* I2C address list */
919
struct i2c_addresses_st {
920
	int card_type;
921
	u32 tuner_addr;
922
	u32 saa7115_addr;
923
	u32 msp34xx_addr;
924
};
925
926
/* for GPIO setting parameter */
927
struct ivtv_gpio_data_st {
928
       int card_type;
929
       int need_init;	/* need to init GPIO? 1:yes 0:no */
930
       u32 direction;	/* GPIO direction (GPIO[0..16]) 0:Input 1:Output */
931
       u32 out_init;	/* GPIO output port init data */
932
       u32 input_mask;	/* for input selection (tuner/line-in/mute) */
933
       u32 input_tuner;
934
       u32 input_line;
935
       u32 mute_mask;   /* for muting */
936
       u32 mute_mute;
937
       u32 mute_unmute;
938
       u32 audio_mask;	/* for tuner's audio mode selection */
939
       u32 audio_mono;
940
       u32 audio_stereo;
941
       u32 audio_main;
942
       u32 audio_sub;
943
       u32 audio_mixed;
944
	   u32 audio_freq_mask;
945
	   u32 audio_32000;
946
	   u32 audio_44100;
947
	   u32 audio_48000;
948
       u32 tuner_mask;	/* for tuner audio status */
949
       u32 tuner_stereo;
950
       u32 tuner_mono;
951
       u32 tuner_multiplex;
952
};
953
954
/* for MSP34XX audio mapping */
955
struct ivtv_msp34xx_audio_map_st {
956
	int card_type;
957
	int tuner;     /* tuner audio input */
958
	int line;      /* line-in audio input */
959
};
960
961
/* for card information/param */
962
struct ivtv_card_params_st {
963
	int            card_type;
964
	unsigned short subsystem_id;
965
	u32            capabilities;
966
	int            stream_count;
967
	char           *card_name;
968
	char           *chip;
969
};
970
860
/* Globals */
971
/* Globals */
861
extern struct ivtv ivtv_cards[];
972
extern struct ivtv ivtv_cards[];
862
extern int ivtv_cards_active;
973
extern int ivtv_cards_active;
Lines 939-944 Link Here
939
extern void ivtv_clear_irq_mask(struct ivtv *itv, unsigned long mask);
1050
extern void ivtv_clear_irq_mask(struct ivtv *itv, unsigned long mask);
940
extern void ivtv_sleep_timeout(int timeout);
1051
extern void ivtv_sleep_timeout(int timeout);
941
1052
1053
/* GPIO stuff */
1054
void ivtv_set_gpio_audio(struct ivtv *itv, int command);
1055
void ivtv_chg_gpio_out(unsigned char *address, u32 mask, u32 write_data);
1056
void ivtv_gpio_write(unsigned char *gpio_addr, u32 data);
1057
int ivtv_get_gpio_audio(struct ivtv *itv, int command);
1058
u32 ivtv_chk_gpio_out(unsigned char *address, u32 mask);
1059
u32 ivtv_gpio_read(unsigned char *gpio_addr);
1060
void ivtv_set_gpio_audiomode(struct ivtv *itv,int audio_mode);
1061
void ivtv_set_gpio_audiofreq(struct ivtv *itv,int audio_freq);
1062
int ivtv_get_gpio_audiomode(struct ivtv *itv);
1063
942
/* Testing/Debugging */
1064
/* Testing/Debugging */
943
extern int ivtv_close(struct ivtv_open_id *id);
1065
extern int ivtv_close(struct ivtv_open_id *id);
944
1066
(-)ivtv/utils/ivtvfwextract.pl (+2 lines)
Lines 43-48 Link Here
43
43
44
$packed_driver_name = "pvr48xxx.exe";
44
$packed_driver_name = "pvr48xxx.exe";
45
$fw_driver_name = "hcwpvrp2.sys";
45
$fw_driver_name = "hcwpvrp2.sys";
46
# for Yuan MPG600/MPG160
47
#$fw_driver_name = "p2driver.sys";
46
$decoder_magic = "a703000066bb55aa";
48
$decoder_magic = "a703000066bb55aa";
47
$encoder_magic = "a70d000066bb55aa";
49
$encoder_magic = "a70d000066bb55aa";
48
50
(-)ivtv/utils/ptune.pl (-1 / +1 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
#
2
#
3
# $Header: /cvsroot/ivtv/ivtv/ivtv/utils/ptune.pl,v 1.12 2003/07/16 03:30:39 pcxuser Exp $
3
# $Header: /home/komoriya/cvsroot/ivtv/utils/ptune.pl,v 1.1.1.1 2003/09/30 13:30:04 komoriya Exp $
4
#
4
#
5
use strict;
5
use strict;
6
6
(-)ivtv/utils/test_ioctl.c (+68 lines)
Lines 41-46 Link Here
41
#define OptSetDebugLevel (1L<<19)
41
#define OptSetDebugLevel (1L<<19)
42
#define OptGetDebugLevel (1L<<20)
42
#define OptGetDebugLevel (1L<<20)
43
#define OptSetVBI			(1L<<21)
43
#define OptSetVBI			(1L<<21)
44
#define OptSetAudioMode			(1L<<21)
45
#define OptSetGPIO			(1L<<22)
44
46
45
/* Codec's specified */
47
/* Codec's specified */
46
#define CAspect			(1L<<1)
48
#define CAspect			(1L<<1)
Lines 114-119 Link Here
114
	printf("                     get frequency for <tuner> [VIDIOC_G_FREQUENCY]\n");
116
	printf("                     get frequency for <tuner> [VIDIOC_G_FREQUENCY]\n");
115
	printf("  -r, --set-freq=tuner=<tuner>,freq=<freq>\n");
117
	printf("  -r, --set-freq=tuner=<tuner>,freq=<freq>\n");
116
	printf("                     sets frequency to <freq> for tuner <tuner> [VIDIOC_S_FREQUENCY]\n");
118
	printf("                     sets frequency to <freq> for tuner <tuner> [VIDIOC_S_FREQUENCY]\n");
119
	printf("  -A, --set-audio-mode=tuner=<tuner>,audio_mode=<mode>\n");
120
	printf("                     sets audio mode to <mode> for tuner <tuner> [VIDIOC_S_TUNER]\n");
121
	printf("                     <mode> = 0:Mono 1:Stereo 2:Lang2/SAP 3:Lang1\n");
117
	printf("  -s, --list-standards\n");
122
	printf("  -s, --list-standards\n");
118
	printf("                     display supported video standards [VIDIOC_ENUMSTD]\n");
123
	printf("                     display supported video standards [VIDIOC_ENUMSTD]\n");
119
	printf("  -t, --get-standard\n");
124
	printf("  -t, --get-standard\n");
Lines 132-137 Link Here
132
	printf("      contrast       =<#> Picture contrast or luma gain. [0 - 127]\n");
137
	printf("      contrast       =<#> Picture contrast or luma gain. [0 - 127]\n");
133
	printf("      volume         =<#> Overall audio volume. [0 - 65535]\n");
138
	printf("      volume         =<#> Overall audio volume. [0 - 65535]\n");
134
	printf("      mute           =<#> Mute audio, i. e. set the volume to zero [boolean]\n");
139
	printf("      mute           =<#> Mute audio, i. e. set the volume to zero [boolean]\n");
140
	printf("  -i --set-gpio=<mode>\n");
141
    printf("                     sets GPIO output to <mode> for debugging.[0x0000-0xffff]\n");
135
	printf("  -D --debug=level   sets/gets the module ivtv_debug variable\n");
142
	printf("  -D --debug=level   sets/gets the module ivtv_debug variable\n");
136
 	exit(0);
143
 	exit(0);
137
}
144
}
Lines 298-303 Link Here
298
		"volume",
305
		"volume",
299
		#define SUB_MUTE			28
306
		#define SUB_MUTE			28
300
		"mute",
307
		"mute",
308
		#define SUB_AUDIO_MODE		29
309
		"audio_mode",
301
		NULL
310
		NULL
302
	};
311
	};
303
312
Lines 326-331 Link Here
326
	struct v4l2_frequency vf;    /* get_freq/set_freq */
335
	struct v4l2_frequency vf;    /* get_freq/set_freq */
327
	struct v4l2_standard vs;     /* list_std */
336
	struct v4l2_standard vs;     /* list_std */
328
	struct msp_matrix mspm;      /* set_io */
337
	struct msp_matrix mspm;      /* set_io */
338
	struct v4l2_tuner vt;        /* set_audio_mode */
339
	__u32 gpio_out = 0x0;        /* GPIO output data */
329
	int debug_level = 0;
340
	int debug_level = 0;
330
	struct ivtv_ioctl_framesync frameinfo;
341
	struct ivtv_ioctl_framesync frameinfo;
331
	struct ivtv_ioctl_vbi_mode vbi_mode;
342
	struct ivtv_ioctl_vbi_mode vbi_mode;
Lines 357-368 Link Here
357
			{"set-input", 1, 0, 0},
368
			{"set-input", 1, 0, 0},
358
			{"get-freq", 1, 0, 0},
369
			{"get-freq", 1, 0, 0},
359
			{"set-freq", 1, 0, 0},
370
			{"set-freq", 1, 0, 0},
371
			{"set-audio-mode", 1, 0, 0},
360
			{"list-standards", 0, 0, 0},
372
			{"list-standards", 0, 0, 0},
361
			{"get-standard", 0, 0, 0},
373
			{"get-standard", 0, 0, 0},
362
			{"set-standard", 1, 0, 0},
374
			{"set-standard", 1, 0, 0},
363
			{"set-io", 1, 0, 0},
375
			{"set-io", 1, 0, 0},
364
			{"list-ctrls", 0, 0, 0},
376
			{"list-ctrls", 0, 0, 0},
365
			{"set-ctrl", 1, 0, 0},
377
			{"set-ctrl", 1, 0, 0},
378
			{"set-gpio", 1, 0, 0},
366
			{"sync", 0, 0, 0},
379
			{"sync", 0, 0, 0},
367
			{"debug", 1, 0, 0},
380
			{"debug", 1, 0, 0},
368
			{0, 0, 0, 0}
381
			{0, 0, 0, 0}
Lines 406-411 Link Here
406
				ch = 'q';
419
				ch = 'q';
407
			else if (!strcmp(long_options[option_index].name, "set-freq"))
420
			else if (!strcmp(long_options[option_index].name, "set-freq"))
408
				ch = 'r';
421
				ch = 'r';
422
			else if (!strcmp(long_options[option_index].name, "set-audio-mode"))
423
				ch = 'A';
409
			else if (!strcmp(long_options[option_index].name, "list-standards"))
424
			else if (!strcmp(long_options[option_index].name, "list-standards"))
410
				ch = 's';
425
				ch = 's';
411
			else if (!strcmp(long_options[option_index].name, "get-standard"))
426
			else if (!strcmp(long_options[option_index].name, "get-standard"))
Lines 418-423 Link Here
418
				ch = 'Y';
433
				ch = 'Y';
419
			else if (!strcmp(long_options[option_index].name, "set-ctrl"))
434
			else if (!strcmp(long_options[option_index].name, "set-ctrl"))
420
				ch = 'y';
435
				ch = 'y';
436
			else if (!strcmp(long_options[option_index].name, "set-gpio"))
437
				ch = 'i';
421
			else if (!strcmp(long_options[option_index].name, "debug"))
438
			else if (!strcmp(long_options[option_index].name, "debug"))
422
				ch = 'D';
439
				ch = 'D';
423
		}
440
		}
Lines 747-752 Link Here
747
					}
764
					}
748
				}
765
				}
749
				break;
766
				break;
767
			case 'A':
768
				set_opts |= OptSetAudioMode;
769
				subs = optarg;
770
				while(*subs != '\0') {
771
					switch(getsubopt(&subs,subopts,&value) ) {
772
						case SUB_TUNER:
773
							if (value == NULL) {
774
								printf("No value given to suboption <tuner>\n");
775
								usage();
776
							}
777
							vt.index = strtol(value, 0L, 0);
778
							break;
779
						case SUB_AUDIO_MODE:
780
							if (value == NULL) {
781
								printf("No value given to suboption <mode>\n");
782
								usage();
783
							}
784
							vt.audmode = strtol(value, 0L, 0);
785
							break;
786
						default:
787
							printf("Invalid suboptions specified\n");
788
							usage();
789
							break;
790
					}
791
				}
792
				break;
750
			case 's':
793
			case 's':
751
				set_opts |= OptListStandards;
794
				set_opts |= OptListStandards;
752
				break;
795
				break;
Lines 824-829 Link Here
824
					}
867
					}
825
				}
868
				}
826
				break;
869
				break;
870
			case 'i':
871
				set_opts |= OptSetGPIO;
872
				gpio_out = strtol(optarg, 0L, 0);
873
				break;
827
			case ':':
874
			case ':':
828
				fprintf(stderr, "Option `%s' requires a value\n", argv[optind]);
875
				fprintf(stderr, "Option `%s' requires a value\n", argv[optind]);
829
				usage();
876
				usage();
Lines 927-932 Link Here
927
			printf("Frequency set to %d\n", vf.frequency);
974
			printf("Frequency set to %d\n", vf.frequency);
928
	}
975
	}
929
976
977
	if (set_opts & OptSetAudioMode) {
978
		__u32 audmode;
979
		audmode = vt.audmode;
980
		if (ioctl(fd, VIDIOC_G_TUNER, &vt) < 0)
981
			fprintf(stderr, "ioctl: VIDIOC_G_TUNER failed\n");
982
		printf("ioctl: VIDIOC_S_TUNER\n");
983
		vt.audmode = audmode;
984
		if (ioctl(fd, VIDIOC_S_TUNER, &vt) < 0)
985
			fprintf(stderr, "ioctl: VIDIOC_S_TUNER failed\n");
986
		else
987
			printf("Audio mode set to %d\n", vt.audmode);
988
	}
989
930
	if (set_opts & OptSetStandard) {
990
	if (set_opts & OptSetStandard) {
931
		printf("ioctl: VIDIOC_S_STD\n");
991
		printf("ioctl: VIDIOC_S_STD\n");
932
		if (ioctl(fd, VIDIOC_S_STD, &std) < 0)
992
		if (ioctl(fd, VIDIOC_S_STD, &std) < 0)
Lines 1121-1126 Link Here
1121
		}
1181
		}
1122
	}
1182
	}
1123
1183
1184
	if (set_opts & OptSetGPIO) {
1185
		printf("set GPIO output to 0x%04X\n", gpio_out);
1186
		vt.index = 0;
1187
		vt.audmode = 0x10000 | gpio_out;
1188
		if (ioctl(fd, VIDIOC_S_TUNER, &vt) < 0)
1189
			fprintf(stderr, "ioctl: VIDIOC_S_TUNER failed\n");
1190
	}
1191
1124
	if (set_opts & OptSetDebugLevel) {
1192
	if (set_opts & OptSetDebugLevel) {
1125
		printf("ioctl: IVTV_IOCTL_SET_DEBUG_LEVEL\n");
1193
		printf("ioctl: IVTV_IOCTL_SET_DEBUG_LEVEL\n");
1126
		new_debug_level = debug_level;
1194
		new_debug_level = debug_level;

Return to bug 45473