aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/emgd/emgd/pal/sdvo/sdvo_intf.c
blob: 403359f5894115833ec9c006c1bbbffdae54ade1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
/* -*- pse-c -*-
 *-----------------------------------------------------------------------------
 * Filename: sdvo_intf.c
 * $Revision: 1.6 $
 *-----------------------------------------------------------------------------
 * Copyright © 2002-2010, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *-----------------------------------------------------------------------------
 * Description:
 *  Functions that provide interface to SDVO device
 *-----------------------------------------------------------------------------
 */

#include "sdvo_port.h"

/* .......................................................................... */
void sdvo_convert_parm_to_dtd(i2c_reg_t parm[16], sdvo_dtd_t *p_dtd);
void sdvo_convert_dtd_to_parm(sdvo_dtd_t *p_dtd, i2c_reg_t parm[16]);


/* .......................................................................... */
/* .......................................................................... */
/*	============================================================================
	Function	:	sdvo_execute_command transfers a command and argument to
					the SDVO device and returns the status of execution

	Parameters	:	opcode		: One of the sdvo_opcode_t opcodes
					num_args 	: Number of arguments 0-8
					p_arg	    : List of arguments
					num_returns	: Expected number of returns 0-8
					p_ret_value	: List of return values

	Remarks 	:	sdvo_execute_command is core function that is called by other
					SDVO interface functions to execute a command.
					The arguments of the command are transferred to the argument
					I2C registers of the SDVO device
					The opcode is then transferred to the opcode I2C register
					It then waits for the command to complete by reading the
					status I2C register up to 3 times

	Returns 	:	sdvo_status_t : Status of command execution
	------------------------------------------------------------------------- */
sdvo_status_t sdvo_execute_command(sdvo_device_context_t *p_ctx,
	sdvo_opcode_t opcode,
	i2c_reg_t num_args,	   i2c_reg_t *p_arg,
	i2c_reg_t num_returns, i2c_reg_t *p_ret_value)
{
	i2c_reg_t status, i;

	/*	..................................................................... */
	/*	Error checking */
	if ((num_args > SDVO_MAX_ARGS) || (num_returns > SDVO_MAX_RETURNS)) {

		return SS_UNSUCCESSFUL;
	}

	if ((num_args > 0) && (p_arg == NULL)) {

		return SS_UNSUCCESSFUL;
	}

	if ((num_returns > 0) && (p_ret_value == NULL)) {

		return SS_UNSUCCESSFUL;
	}

	/*	..................................................................... */
	/*	Write the arguments and the opcode */
	for (i = 0; i < num_args; i++) {

		if (! sdvo_write_i2c_reg(p_ctx, (i2c_reg_t)(SDVO_REG_ARG_START - i),
				p_arg[i])) {

			return SS_WRITE_FAILED;
		}
	}

	if (! sdvo_write_i2c_reg(p_ctx, (i2c_reg_t)SDVO_REG_OPCODE,
			(i2c_reg_t)opcode)) {

		return SS_WRITE_FAILED;
	}

	/*	..................................................................... */
	/*	Wait for command to complete */
	for (i = 0; i < SDVO_MAX_RETRIES; i++) {

		if (! sdvo_read_i2c_reg(p_ctx, SDVO_REG_STATUS, &status)) {

			return SS_READ_FAILED;
		}

		if (status != SS_PENDING) {

			break;
		}
	}

	/*	..................................................................... */
	/*	Read the return parameters if command succeeded */
	if (status == SS_SUCCESS) {

		for (i = 0; i < num_returns; i++) {

			if (! sdvo_read_i2c_reg(p_ctx, SDVO_REG_RETURN_START + i,
					&p_ret_value[i])) {

				 return SS_READ_FAILED;
			}
		}
	}

	return status;
}

sdvo_status_t sdvo_execute_command_read (sdvo_device_context_t *p_ctx,
	i2c_reg_t num_returns, i2c_reg_t *p_ret_value)
{
	i2c_reg_t status, i;

	for (i = 0; i < SDVO_MAX_RETRIES; i++) {
		if (!sdvo_read_i2c_reg(p_ctx, SDVO_REG_STATUS, &status)) {
			return SS_READ_FAILED;
		}

		if (status != SS_PENDING) {
			break;
		}
	}

	/*	Read the return parameters if command succeeded */
	if (status == SS_SUCCESS) {
		for (i = 0; i < num_returns; i++) {
			if (! sdvo_read_i2c_reg(p_ctx, SDVO_REG_RETURN_START + i,
					&p_ret_value[i])) {
				 return SS_READ_FAILED;
			}
		}
	}
	return status;
}

#ifndef CONFIG_MICRO
sdvo_status_t sdvo_reset(sdvo_device_context_t *p_ctx)
{
	return sdvo_execute_command(p_ctx, RESET,
							   0, NULL,
							   0, NULL);
}
#endif

sdvo_status_t sdvo_get_device_capabilities(sdvo_device_context_t *p_ctx,
	sdvo_device_capabilities_t *p_Dev_Cap)
{
	return sdvo_execute_command(p_ctx, GET_DEVICE_CAPABILITIES,
							    0, NULL,
							    8, (i2c_reg_t *)p_Dev_Cap);
}


sdvo_status_t sdvo_get_trained_inputs(sdvo_device_context_t *p_ctx,
	i2c_reg_t *p_Out)
{
	return sdvo_execute_command(p_ctx, GET_TRAINED_INPUTS,
							   0, NULL,
							   1, p_Out);
}


sdvo_status_t sdvo_get_active_outputs(sdvo_device_context_t *p_ctx,
	sdvo_output_flags_t *p_Out_Flags)
{
	return sdvo_execute_command(p_ctx, GET_ACTIVE_OUTPUTS,
				0, NULL,
				2, (i2c_reg_t *)p_Out_Flags);
}


sdvo_status_t sdvo_set_active_outputs(sdvo_device_context_t *p_ctx,
	sdvo_output_flags_t out_flags)
{
	return sdvo_execute_command(p_ctx, SET_ACTIVE_OUTPUTS,
			   2, (i2c_reg_t *)&out_flags,
			   0, NULL);
}


#ifndef CONFIG_MICRO
sdvo_status_t sdvo_get_in_out_map(sdvo_device_context_t *p_ctx,
	sdvo_output_flags_t out_flags[2])
{
	return sdvo_execute_command(p_ctx, GET_IN_OUT_MAP,
				0, NULL,
				4, (i2c_reg_t *)out_flags);
}
#endif

sdvo_status_t sdvo_set_in_out_map(sdvo_device_context_t *p_ctx,
	sdvo_output_flags_t out_flags[2])
{
	return sdvo_execute_command(p_ctx, SET_IN_OUT_MAP,
				4, (i2c_reg_t *)out_flags,
				0, NULL);
}


sdvo_status_t sdvo_get_attached_displays(sdvo_device_context_t *p_ctx,
	sdvo_output_flags_t *p_Out_Flags)
{
	i2c_reg_t status, i;

	status = sdvo_execute_command(p_ctx, GET_ATTACHED_DISPLAYS,
				0, NULL,
				2, (i2c_reg_t *)p_Out_Flags);


	PD_DEBUG("sdvo: GET_ATTACHED_DISPLAYS status = %d]",  status);
	for (i=0; i<5; i++) {
		if (status == SS_SUCCESS)
			break;
		else {
			pd_ui_usleep(50000); /* wait for 50ms */
			status = sdvo_execute_command_read(p_ctx, 2, (i2c_reg_t *)p_Out_Flags);
		}
	}

	PD_DEBUG("sdvo: sdvo_execute_command_read- no. of tries = [%d]",  i);
	return status;
}


sdvo_status_t sdvo_set_target_input(sdvo_device_context_t *p_ctx,
	sdvo_target_input_t input)
{
	i2c_reg_t arg_value = input == SDVO0 ? 0 : 1;

	return sdvo_execute_command(p_ctx, SET_TARGET_INPUT,
				1, (i2c_reg_t *)&arg_value,
				0, NULL);
}


sdvo_status_t sdvo_set_target_output(sdvo_device_context_t *p_ctx,
		sdvo_output_flags_t out_flags)
{
	return sdvo_execute_command(p_ctx, SET_TARGET_OUTUT,
			   2, (i2c_reg_t *)&out_flags,
			   0, NULL);
}

#ifndef CONFIG_MICRO
sdvo_status_t sdvo_get_input_timings(sdvo_device_context_t *p_ctx,
								 sdvo_dtd_t *p_dtd)
{
	sdvo_status_t status;
	i2c_reg_t ret[16];

	status = sdvo_execute_command(p_ctx, GET_INPUT_TIMINGS_PART1,
				0, NULL,
				8, ret);
	if (status != SS_SUCCESS) {

		return status;
	}

	status = sdvo_execute_command(p_ctx, GET_INPUT_TIMINGS_PART2,
				 0, NULL,
				 8, &ret[8]);
	if (status != SS_SUCCESS) {

		return status;
	}

	sdvo_convert_parm_to_dtd(ret, p_dtd);

	return status;
}
#endif

sdvo_status_t sdvo_set_input_timings(sdvo_device_context_t *p_ctx,
								 sdvo_dtd_t *p_dtd)
{
	sdvo_status_t status;
	i2c_reg_t parm[16];

	sdvo_convert_dtd_to_parm(p_dtd, parm);

	status = sdvo_execute_command(p_ctx, SET_INPUT_TIMINGS_PART1,
				 8, parm,
				 0, NULL);

	if ((status != SS_SUCCESS) && (status != SS_NOT_SUPPORTED)) {

		return status;
	}

	status = sdvo_execute_command(p_ctx, SET_INPUT_TIMINGS_PART2,
				 8, &parm[8],
				 0, NULL);

	return status;
}

#ifndef CONFIG_MICRO
sdvo_status_t sdvo_get_output_timings(sdvo_device_context_t *p_ctx,
	sdvo_dtd_t *p_dtd)
{
	sdvo_status_t status;
	i2c_reg_t ret[16];

	status = sdvo_execute_command(p_ctx, GET_OUTPUT_TIMINGS_PART1,
				 0, NULL,
				 8, ret);
	if ((status != SS_SUCCESS) && (status != SS_NOT_SUPPORTED)) {

		return status;
	}

	status = sdvo_execute_command(p_ctx, GET_OUTPUT_TIMINGS_PART2,
				 0, NULL,
				 8, &ret[8]);
	if (status != SS_SUCCESS) {

		return status;
	}

	sdvo_convert_parm_to_dtd(ret, p_dtd);

	return status;
}
#endif

sdvo_status_t sdvo_set_output_timings(sdvo_device_context_t *p_ctx,
  sdvo_dtd_t *p_dtd)
{
	sdvo_status_t status;
	i2c_reg_t parm[16];

	sdvo_convert_dtd_to_parm(p_dtd, parm);

	status = sdvo_execute_command(p_ctx, SET_OUTPUT_TIMINGS_PART1,
				 8, parm,
				 0, NULL);

	if (status != SS_SUCCESS) {

		return status;
	}

	status = sdvo_execute_command(p_ctx, SET_OUTPUT_TIMINGS_PART2,
				 8, &parm[8],
				 0, NULL);

	return status;
}


sdvo_status_t sdvo_get_preferred_input_timings(sdvo_device_context_t *p_ctx,
				  sdvo_create_preferred_timings_t *p_Timings,
				  sdvo_dtd_t *p_dtd)
{
	sdvo_status_t status;
	i2c_reg_t ret[16];

	/*	..................................................................... */
	status = sdvo_execute_command(p_ctx, CREATE_PREFERRED_INPUT_TIMINGS,
				 7, (i2c_reg_t *)p_Timings,
				 0, NULL);
	if (status != SS_SUCCESS) {

		return status;
	}

	/*	..................................................................... */
	status =  sdvo_execute_command(p_ctx, GET_PREFERRED_INPUT_TIMINGS_PART1,
				  0, NULL,
				  8, ret);
	if (status != SS_SUCCESS) {

		return status;
	}

	status = sdvo_execute_command(p_ctx, GET_PREFERRED_INPUT_TIMINGS_PART2,
				 0, NULL,
				 8, &ret[8]);
	if (status != SS_SUCCESS) {

		return status;
	}

	/*	..................................................................... */
	sdvo_convert_parm_to_dtd(ret, p_dtd);

	return status;
}


/*	in_clock[0] = min, in_clock[1] = max */
sdvo_status_t sdvo_get_input_pixel_clock_range(sdvo_device_context_t *p_ctx,
	unsigned short in_clock[2])
{
	return sdvo_execute_command(p_ctx, GET_INPUT_PIXEL_CLOCK_RANGE,
			   0, NULL,
			   4, (i2c_reg_t *)in_clock);
}

#ifndef CONFIG_MICRO
/*	out_Clock[0] = min, out_Clock[1] = max */
sdvo_status_t sdvo_get_output_pixel_clock_range(sdvo_device_context_t *p_ctx,
				  unsigned short out_Clock[2])
{
	return sdvo_execute_command(p_ctx, GET_OUTPUT_PIXEL_CLOCK_RANGE,
			   0, NULL,
			   4, (i2c_reg_t *)out_Clock);
}

sdvo_status_t sdvo_get_clock_rate_multiplier(sdvo_device_context_t *p_ctx,
	sdvo_clock_rate_mult_t *p_mult)
{
	*p_mult = 0;

	return sdvo_execute_command(p_ctx, GET_SDVO_CLOCK_RATE_MULTIPLIER,
			   0, NULL,
			   1, (i2c_reg_t *)p_mult);
}
#endif


sdvo_status_t sdvo_set_clock_rate_multiplier(sdvo_device_context_t *p_ctx,
	sdvo_clock_rate_mult_t mult)
{
	return sdvo_execute_command(p_ctx, SET_SDVO_CLOCK_RATE_MULTIPLIER,
			   1, (i2c_reg_t *)&mult,
			   0, NULL);
}


sdvo_status_t sdvo_get_supported_power_states(sdvo_device_context_t *p_ctx,
	 i2c_reg_t *p_pwr_state)
{
	return sdvo_execute_command(p_ctx, GET_SUPPORTED_POWER_STATES,
			   0, NULL,
			   1, p_pwr_state);
}


sdvo_status_t sdvo_get_power_state(sdvo_device_context_t *p_ctx,
	   i2c_reg_t *p_pwr_state)
{
	return sdvo_execute_command(p_ctx, GET_POWER_STATE,
			   0, NULL,
			   1, p_pwr_state);
}


sdvo_status_t sdvo_set_power_state(sdvo_device_context_t *p_ctx,
   i2c_reg_t pwr_state)
{
	return sdvo_execute_command(p_ctx, SET_POWER_STATE,
			   1, &pwr_state,
			   0, NULL);
}


sdvo_status_t sdvo_set_display_power_state(sdvo_device_context_t *p_ctx,
  i2c_reg_t disp_pwr_state)
{
	return sdvo_execute_command(p_ctx, SET_DISPLAY_POWER_STATE,
			   1, &disp_pwr_state,
			   0, NULL);
}
#if !defined(CONFIG_MICRO)
sdvo_status_t sdvo_set_digital_encoding_mode(sdvo_device_context_t *p_ctx,
  i2c_reg_t digital_encoding_mode)
{
	return sdvo_execute_command(p_ctx, SET_DIGITAL_ENCODING_MODE,
			   1, &digital_encoding_mode,
			   0, NULL);
}
sdvo_status_t sdvo_get_hdmi_audio_transmission_char(sdvo_device_context_t *p_ctx,
  i2c_reg_t *hdmi_reg)
{
	return sdvo_execute_command(p_ctx, GET_HDMI_AUDIO_TRANSMISSION_CHARACTERISTICS,
			   0, NULL,
			   3, (i2c_reg_t*)hdmi_reg);
}
sdvo_status_t sdvo_get_supported_encoding_modes(sdvo_device_context_t *p_ctx,
  sdvo_digital_encode_modes_t *digital_encoding_modes)
{
	return sdvo_execute_command(p_ctx, GET_SUPPORTED_DIGITAL_ENCODING_MODES,
			   0, NULL,
			   8, (i2c_reg_t*)digital_encoding_modes);
}

sdvo_status_t sdvo_get_digital_encoding_mode(sdvo_device_context_t *p_ctx,
  i2c_reg_t *digital_encoding_mode)
{
	return sdvo_execute_command(p_ctx, GET_DIGITAL_ENCODING_MODE,
			   0, NULL,
			   1, (i2c_reg_t*)digital_encoding_mode);
}
/* ------------------------------------------------------------------------- */
#endif
sdvo_status_t sdvo_set_upscalar_coefficient(sdvo_device_context_t *p_ctx,
  i2c_reg_t upscalar_coefficient)
{
	return sdvo_execute_command(p_ctx, SET_UPSCALAR_COEFFICIENTS,
			   1, &upscalar_coefficient,
			   0, NULL);
}

sdvo_status_t sdvo_get_tv_output_format(sdvo_device_context_t *p_ctx,
	i2c_reg_t *p_TV_Output_Format_Flag)
{
	return sdvo_execute_command(p_ctx, GET_TV_OUTPUT_FORMAT,
				0, NULL,
				6, p_TV_Output_Format_Flag);
}

sdvo_status_t sdvo_get_sdtv_resolution_support(sdvo_device_context_t *p_ctx,
	i2c_reg_t *p_Requested_SDTV_Format_Flag,
	i2c_reg_t *p_Resolution_Support_Flags)
{
	return sdvo_execute_command(p_ctx, GET_SDTV_RESOLUTION_SUPPORT,
				3, p_Requested_SDTV_Format_Flag,
				3, p_Resolution_Support_Flags);
}

sdvo_status_t sdvo_get_scaled_hdtv_resolution_support(sdvo_device_context_t *p_ctx,
	i2c_reg_t *p_Requested_HDTV_Format_Flag,
	i2c_reg_t *p_Resolution_Support_Flags)
{
	return sdvo_execute_command(p_ctx, GET_SCALED_HDTV_RESOLUTION_SUPPORT,
				4, p_Requested_HDTV_Format_Flag,
				8, p_Resolution_Support_Flags);
}

void sdvo_convert_parm_to_dtd(i2c_reg_t parm[16], sdvo_dtd_t *p_dtd)
{
	pd_memset(p_dtd, 0, sizeof(sdvo_dtd_t));

	p_dtd->pixel_clock			= (parm[1] << 8) | parm[0];
	p_dtd->horz_active			= ((parm[4] & 0xF0) << 4) | parm[2];
	p_dtd->horz_blanking		= ((parm[4] & 0x0F) << 8) | parm[3];
	p_dtd->vert_active			= ((parm[7] & 0xF0) << 4) | parm[5];
	p_dtd->vert_blanking		= ((parm[7] & 0x0F) << 8) | parm[6];
	p_dtd->horz_sync_offset		= ((parm[11] & 0xC0) << 2) | parm[8];
	p_dtd->horz_sync_pulse_width= ((parm[11] & 0x30) << 4) | parm[9];
	p_dtd->vert_sync_offset		= (parm[14] & 0xC0) | ((parm[11] & 0x0C) << 2) |
								  ((parm[10] & 0xF0) >> 4);
	p_dtd->vert_sync_pulse_width= ((parm[11] & 0x03) << 4) | (parm[10] & 0x0F);
	p_dtd->dtd_flags			= parm[12];
	p_dtd->sdvo_flags			= parm[13];
}


void sdvo_convert_dtd_to_parm(sdvo_dtd_t *p_dtd, i2c_reg_t parm[16])
{
	parm[0]  = (p_dtd->pixel_clock & 0xFF);
	parm[1]  = ((p_dtd->pixel_clock & 0xFF00) >> 8);
	parm[2]  = (p_dtd->horz_active & 0xFF);
	parm[3]  = (p_dtd->horz_blanking & 0xFF);
	parm[4]  = ((p_dtd->horz_active & 0xF00) >> 4) |
				((p_dtd->horz_blanking & 0xF00) >> 8);
	parm[5]  = (p_dtd->vert_active & 0xFF);
	parm[6]  = (p_dtd->vert_blanking & 0xFF);
	parm[7]  = ((p_dtd->vert_active & 0xF00) >> 4) |
				((p_dtd->vert_blanking & 0xF00) >> 8);
	parm[8]  = (p_dtd->horz_sync_offset & 0xFF);
	parm[9]  = (p_dtd->horz_sync_pulse_width & 0xFF);
	parm[10] = ((p_dtd->vert_sync_offset & 0x0F) << 4) |
				(p_dtd->vert_sync_pulse_width & 0x0F);
	parm[11] = ((p_dtd->horz_sync_offset & 0x300) >> 2) |
			   ((p_dtd->horz_sync_pulse_width & 0x300) >> 4) |
			   ((p_dtd->vert_sync_offset & 0x30) >> 2) |
			   ((p_dtd->vert_sync_pulse_width & 0x30) >> 4);
	parm[12] = p_dtd->dtd_flags;
	parm[13] = p_dtd->sdvo_flags;
	parm[14] = p_dtd->vert_sync_offset & 0xC0;
}

#ifndef CONFIG_MICRO
sdvo_status_t sdvo_get_min_max_pixel_clock(sdvo_device_context_t *p_ctx,
	unsigned long *p_min_clock,
	unsigned long *p_max_clock)
{
	sdvo_status_t status;
	sdvo_clock_rate_mult_t clock_mult;
	unsigned short in_range[2], out_range[2];

	status = sdvo_get_clock_rate_multiplier(p_ctx, &clock_mult);
	if (status != SS_SUCCESS) {

		return status;
	}

	status = sdvo_get_input_pixel_clock_range(p_ctx, in_range);
	if (status != SS_SUCCESS) {

		return status;
	}

	status = sdvo_get_output_pixel_clock_range(p_ctx, out_range);
	if (status != SS_SUCCESS) {

		return status;
	}

	switch (clock_mult)
	{
		case CRM_1X :
			break;

		case CRM_2X :
			in_range[0] *= 2;
			break;

		case CRM_4X :
			in_range[0] *= 4;
			break;

		default :
			return SS_INVALID_RETURN;
	}

	/*	Minimum pixel clock supported is the maximum of min input/output */
	/*  pixel clock */
	*p_min_clock = in_range[0] > out_range[0] ? in_range[0] : out_range[0];

	/*	Maximum pixel clock supported is minimum of max pixel clock of */
	/*	encoder and SDVO bus clock rate */
	*p_max_clock = in_range[1] < out_range[1] ? in_range[1] : out_range[1];

	return SS_SUCCESS;
}
#endif

unsigned char sdvo_write_i2c_reg(sdvo_device_context_t *p_ctx, i2c_reg_t offset,
	i2c_reg_t value)
{
	pd_reg_t reg_list[2];

/*	PD_DEBUG("sdvo : W : 0x%02x, 0x%02x", offset, value); */

	reg_list[0].reg = offset;
	reg_list[0].value = value;

	reg_list[1].reg = PD_REG_LIST_END;

	if (p_ctx->p_callback->write_regs(p_ctx->p_callback->callback_context, reg_list,
			PD_REG_I2C)) {

		return FALSE;

	}else {

		return TRUE;
	}
}


unsigned char sdvo_read_i2c_reg(sdvo_device_context_t *p_ctx, unsigned char offset,
						i2c_reg_t *p_Value)
{
	pd_reg_t reg_list[2];

	reg_list[0].reg = offset;
	reg_list[1].reg = PD_REG_LIST_END;

	if (p_ctx->p_callback->read_regs(p_ctx->p_callback->callback_context, reg_list,
								   PD_REG_I2C)) {

		return FALSE;

	} else {

		*p_Value = (i2c_reg_t)reg_list[0].value;

/*		PD_DEBUG("sdvo : R : 0x%02x, 0x%02x", offset, *p_Value); */

		return TRUE;
	}
}