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
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
|
/*
* Copyright (c) 2006 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Neither the name of the Advanced Micro Devices, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*/
/*
* Cimarron VIP configuration routines.
*/
/*---------------------------------------------------------------------------
* vip_initialize
*
* This routine initializes the internal module state and prepares the
* module for subsequent VIP orientated activities.
*--------------------------------------------------------------------------*/
int
vip_initialize(VIPSETMODEBUFFER * buffer)
{
unsigned long vip_control1, vip_control2, vip_control3;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
vip_control1 = 0;
vip_control2 = 0;
vip_control3 = 0;
/* CONFIGURE CONTROL WORDS BASED ON MODE STRUCTURE */
/* Note that some of the input parameters match the register fields */
/* they represent. */
/* STREAM ENABLES */
vip_control1 |= buffer->stream_enables;
/* VIP CAPTURE MODE */
vip_control1 |= buffer->operating_mode;
/* HANDLE PLANAR CAPTURE */
if (buffer->flags & VIP_MODEFLAG_PLANARCAPTURE) {
vip_control1 |= VIP_CONTROL1_PLANAR;
if (buffer->planar_capture == VIP_420CAPTURE_EVERYLINE) {
vip_control1 |= VIP_CONTROL1_DISABLE_DECIMATION;
}
else if (buffer->planar_capture == VIP_420CAPTURE_ALTERNATINGFIELDS) {
if (buffer->flags & VIP_MODEFLAG_PROGRESSIVE)
return CIM_STATUS_INVALIDPARAMS;
vip_control1 |= VIP_CONTROL1_DISABLE_DECIMATION;
vip_control3 |= VIP_CONTROL3_DECIMATE_EVEN;
}
else if (buffer->planar_capture != VIP_420CAPTURE_ALTERNATINGLINES)
return CIM_STATUS_INVALIDPARAMS;
/* CONFIGURE THE VIDEO FIFO THRESHOLD BASED ON THE FIFO DEPTH */
vip_control2 |= VIP_CONTROL2_DEFAULT_VIDTH_420 <<
VIP_CONTROL2_VIDTH_SHIFT;
}
else {
vip_control2 |= VIP_CONTROL2_DEFAULT_VIDTH_422 <<
VIP_CONTROL2_VIDTH_SHIFT;
}
/* CONFIGURE DEFAULT ANCILARRY THRESHOLD AND VIDEO FLUSH VALUES */
vip_control2 |= VIP_CONTROL2_DEFAULT_ANCTH << VIP_CONTROL2_ANCTH_SHIFT;
vip_control1 |= VIP_CONTROL1_DEFAULT_ANC_FF << VIP_CONTROL1_ANC_FF_SHIFT;
vip_control1 |= VIP_CONTROL1_DEFAULT_VID_FF << VIP_CONTROL1_VID_FF_SHIFT;
/* PROGRAM VIP OPTIONS */
/* The options are sanitized based on the current configuration. */
if (buffer->flags & VIP_MODEFLAG_PROGRESSIVE)
vip_control1 |= VIP_CONTROL1_NON_INTERLACED;
else {
if (buffer->flags & VIP_MODEFLAG_TOGGLEEACHFIELD)
vip_control3 |= VIP_CONTROL3_BASE_UPDATE;
if (buffer->flags & VIP_MODEFLAG_INVERTPOLARITY)
vip_control2 |= VIP_CONTROL2_INVERT_POLARITY;
}
if ((buffer->operating_mode == VIP_MODE_MSG ||
buffer->operating_mode == VIP_MODE_DATA) &&
(buffer->flags & VIP_MODEFLAG_FLIPMESSAGEWHENFULL)) {
vip_control1 |= VIP_CONTROL1_MSG_STRM_CTRL;
}
else if (buffer->operating_mode == VIP_MODE_VIP2_8BIT ||
buffer->operating_mode == VIP_MODE_VIP2_16BIT) {
if (buffer->flags & VIP_MODEFLAG_ENABLEREPEATFLAG)
vip_control2 |= VIP_CONTROL2_REPEAT_ENABLE;
if (buffer->flags & VIP_MODEFLAG_INVERTTASKPOLARITY)
vip_control3 |= VIP_CONTROL3_TASK_POLARITY;
}
if (buffer->flags & VIP_MODEFLAG_DISABLEZERODETECT)
vip_control1 |= VIP_CONTROL1_DISABLE_ZERO_DETECT;
if (buffer->flags & VIP_MODEFLAG_10BITANCILLARY)
vip_control2 |= VIP_CONTROL2_ANC10;
/* WRITE THE CONTROL REGISTERS */
/* The control registers are kept 'live' to allow separate instances of */
/* Cimarron to control the VIP hardware. */
WRITE_VIP32(VIP_CONTROL1, vip_control1);
WRITE_VIP32(VIP_CONTROL2, vip_control2);
WRITE_VIP32(VIP_CONTROL3, vip_control3);
/* CONFIGURE 601 PARAMETERS */
if (buffer->operating_mode == VIP_MODE_8BIT601 ||
buffer->operating_mode == VIP_MODE_16BIT601) {
vip_update_601_params(&buffer->vip601_settings);
}
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_update_601_params
*
* This routine configures all aspects of 601 VIP data capture, including
* start and stop timings and input polarities.
*--------------------------------------------------------------------------*/
int
vip_update_601_params(VIP_601PARAMS * buffer)
{
unsigned long vip_control3, vip_control1;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
vip_control1 = READ_VIP32(VIP_CONTROL3);
vip_control3 = READ_VIP32(VIP_CONTROL3);
if (buffer->flags & VIP_MODEFLAG_VSYNCACTIVEHIGH)
vip_control3 |= VIP_CONTROL3_VSYNC_POLARITY;
else
vip_control3 &= ~VIP_CONTROL3_VSYNC_POLARITY;
if (buffer->flags & VIP_MODEFLAG_HSYNCACTIVEHIGH)
vip_control3 |= VIP_CONTROL3_HSYNC_POLARITY;
else
vip_control3 &= ~VIP_CONTROL3_HSYNC_POLARITY;
WRITE_VIP32(VIP_CONTROL3, vip_control3);
WRITE_VIP32(VIP_601_HORZ_START, buffer->horz_start);
WRITE_VIP32(VIP_601_VBI_START, buffer->vbi_start);
WRITE_VIP32(VIP_601_VBI_END, buffer->vbi_start + buffer->vbi_height - 1);
WRITE_VIP32(VIP_601_EVEN_START_STOP,
buffer->vert_start_even | ((buffer->vert_start_even +
buffer->even_height - 1) << 16));
WRITE_VIP32(VIP_601_ODD_START_STOP,
buffer->vert_start_odd | ((buffer->vert_start_odd +
buffer->odd_height - 1) << 16));
WRITE_VIP32(VIP_ODD_FIELD_DETECT,
buffer->odd_detect_start | (buffer->odd_detect_end << 16));
/* SPECIAL CASE FOR HORIZONTAL DATA
* 601 horizontal parameters are based on the number of clocks and not
* the number of pixels.
*/
if ((vip_control1 & VIP_CONTROL1_MODE_MASK) == VIP_MODE_16BIT601)
WRITE_VIP32(VIP_601_HORZ_END,
buffer->horz_start + (buffer->width << 1) + 3);
else
WRITE_VIP32(VIP_601_HORZ_END, buffer->horz_start + buffer->width + 3);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_configure_capture_buffers
*
* This routine configures the base offsets for video, ancillary or message
* mode capture. The input structure can also contain multiple offsets, such
* that the calling application can avoid updating the structure for each
* flip.
*
* The new buffer addresses are written to the hardware registers although
* they may not be latched immediately. Calling vip_is_buffer_update_latched
* allows the determination of whether the update has occured.
*
* Review the Cimarron VIP API documentation to determine which buffer
* addresses are latched immediately.
*--------------------------------------------------------------------------*/
int
vip_configure_capture_buffers(int buffer_type, VIPINPUTBUFFER * buffer)
{
VIPINPUTBUFFER_ADDR *offsets;
unsigned long cur_buffer = buffer->current_buffer;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
if (buffer_type == VIP_BUFFER_A || buffer_type == VIP_BUFFER_601) {
offsets = &buffer->offsets[VIP_BUFFER_TASK_A];
/* SET VIDEO PITCH */
WRITE_VIP32(VIP_TASKA_VID_PITCH,
offsets->y_pitch | (offsets->uv_pitch << 16));
/* SET BASE OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_INVERTPOLARITY) {
WRITE_VIP32(VIP_TASKA_VID_ODD_BASE, offsets->even_base[cur_buffer]);
WRITE_VIP32(VIP_TASKA_VID_EVEN_BASE, offsets->odd_base[cur_buffer]);
if (buffer->flags & VIP_INPUTFLAG_VBI) {
WRITE_VIP32(VIP_TASKA_VBI_ODD_BASE, offsets->vbi_even_base);
WRITE_VIP32(VIP_TASKA_VBI_EVEN_BASE, offsets->vbi_odd_base);
}
}
else {
WRITE_VIP32(VIP_TASKA_VID_ODD_BASE, offsets->odd_base[cur_buffer]);
WRITE_VIP32(VIP_TASKA_VID_EVEN_BASE,
offsets->even_base[cur_buffer]);
if (buffer->flags & VIP_INPUTFLAG_VBI) {
WRITE_VIP32(VIP_TASKA_VBI_ODD_BASE, offsets->vbi_odd_base);
WRITE_VIP32(VIP_TASKA_VBI_EVEN_BASE, offsets->vbi_even_base);
}
}
/* SET 4:2:0 OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_PLANAR) {
WRITE_VIP32(VIP_TASKA_U_OFFSET, offsets->odd_uoffset);
WRITE_VIP32(VIP_TASKA_V_OFFSET, offsets->odd_voffset);
WRITE_VIP32(VIP_TASKA_U_EVEN_OFFSET, offsets->even_uoffset);
WRITE_VIP32(VIP_TASKA_V_EVEN_OFFSET, offsets->even_voffset);
}
}
else if (buffer_type == VIP_BUFFER_B) {
offsets = &buffer->offsets[VIP_BUFFER_TASK_B];
/* SET VIDEO PITCH */
WRITE_VIP32(VIP_TASKB_VID_PITCH,
offsets->y_pitch | (offsets->uv_pitch << 16));
/* SET BASE OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_INVERTPOLARITY) {
WRITE_VIP32(VIP_TASKB_VID_ODD_BASE, offsets->even_base[cur_buffer]);
WRITE_VIP32(VIP_TASKB_VID_EVEN_BASE, offsets->odd_base[cur_buffer]);
if (buffer->flags & VIP_INPUTFLAG_VBI) {
WRITE_VIP32(VIP_TASKB_VBI_ODD_BASE, offsets->vbi_even_base);
WRITE_VIP32(VIP_TASKB_VBI_EVEN_BASE, offsets->vbi_odd_base);
}
}
else {
WRITE_VIP32(VIP_TASKB_VID_ODD_BASE, offsets->odd_base[cur_buffer]);
WRITE_VIP32(VIP_TASKB_VID_EVEN_BASE,
offsets->even_base[cur_buffer]);
if (buffer->flags & VIP_INPUTFLAG_VBI) {
WRITE_VIP32(VIP_TASKB_VBI_ODD_BASE, offsets->vbi_odd_base);
WRITE_VIP32(VIP_TASKB_VBI_EVEN_BASE, offsets->vbi_even_base);
}
}
/* SET 4:2:0 OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_PLANAR) {
WRITE_VIP32(VIP_TASKB_U_OFFSET, offsets->odd_uoffset);
WRITE_VIP32(VIP_TASKB_V_OFFSET, offsets->odd_voffset);
}
}
else if (buffer_type == VIP_BUFFER_ANC || buffer_type == VIP_BUFFER_MSG) {
WRITE_VIP32(VIP_ANC_MSG1_BASE, buffer->ancillaryData.msg1_base);
WRITE_VIP32(VIP_ANC_MSG2_BASE, buffer->ancillaryData.msg2_base);
WRITE_VIP32(VIP_ANC_MSG_SIZE, buffer->ancillaryData.msg_size);
}
else {
return CIM_STATUS_INVALIDPARAMS;
}
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_toggle_vip_video_offsets
*
* This routine updates the offsets for video capture. It is a simplified
* version of vip_configure_capture_buffers that is designed to be called from
* interrupt service routines or other buffer flipping applications that
* require low latency.
*--------------------------------------------------------------------------*/
int
vip_toggle_video_offsets(int buffer_type, VIPINPUTBUFFER * buffer)
{
unsigned long cur_buffer = buffer->current_buffer;
VIPINPUTBUFFER_ADDR *offsets;
if (buffer_type == VIP_BUFFER_A) {
offsets = &buffer->offsets[VIP_BUFFER_TASK_A];
/* SET BASE OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_INVERTPOLARITY) {
WRITE_VIP32(VIP_TASKA_VID_ODD_BASE, offsets->even_base[cur_buffer]);
WRITE_VIP32(VIP_TASKA_VID_EVEN_BASE, offsets->odd_base[cur_buffer]);
}
else {
WRITE_VIP32(VIP_TASKA_VID_ODD_BASE, offsets->odd_base[cur_buffer]);
WRITE_VIP32(VIP_TASKA_VID_EVEN_BASE,
offsets->even_base[cur_buffer]);
}
}
else if (buffer_type == VIP_BUFFER_B) {
offsets = &buffer->offsets[VIP_BUFFER_TASK_B];
/* SET BASE OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_INVERTPOLARITY) {
WRITE_VIP32(VIP_TASKB_VID_ODD_BASE, offsets->even_base[cur_buffer]);
WRITE_VIP32(VIP_TASKB_VID_EVEN_BASE, offsets->odd_base[cur_buffer]);
}
else {
WRITE_VIP32(VIP_TASKB_VID_ODD_BASE, offsets->odd_base[cur_buffer]);
WRITE_VIP32(VIP_TASKB_VID_EVEN_BASE,
offsets->even_base[cur_buffer]);
}
}
else if (buffer_type == VIP_BUFFER_A_ODD) {
offsets = &buffer->offsets[VIP_BUFFER_TASK_A];
/* SET BASE OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_INVERTPOLARITY)
WRITE_VIP32(VIP_TASKA_VID_ODD_BASE, offsets->even_base[cur_buffer]);
else
WRITE_VIP32(VIP_TASKA_VID_ODD_BASE, offsets->odd_base[cur_buffer]);
}
else if (buffer_type == VIP_BUFFER_A_EVEN) {
offsets = &buffer->offsets[VIP_BUFFER_TASK_A];
/* SET BASE OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_INVERTPOLARITY)
WRITE_VIP32(VIP_TASKA_VID_EVEN_BASE, offsets->odd_base[cur_buffer]);
else
WRITE_VIP32(VIP_TASKA_VID_EVEN_BASE,
offsets->even_base[cur_buffer]);
}
else if (buffer_type == VIP_BUFFER_B_ODD) {
offsets = &buffer->offsets[VIP_BUFFER_TASK_B];
/* SET BASE OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_INVERTPOLARITY)
WRITE_VIP32(VIP_TASKB_VID_ODD_BASE, offsets->even_base[cur_buffer]);
else
WRITE_VIP32(VIP_TASKB_VID_ODD_BASE, offsets->odd_base[cur_buffer]);
}
else if (buffer_type == VIP_BUFFER_B_EVEN) {
offsets = &buffer->offsets[VIP_BUFFER_TASK_B];
/* SET BASE OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_INVERTPOLARITY)
WRITE_VIP32(VIP_TASKB_VID_EVEN_BASE, offsets->odd_base[cur_buffer]);
else
WRITE_VIP32(VIP_TASKB_VID_EVEN_BASE,
offsets->even_base[cur_buffer]);
}
else
return CIM_STATUS_INVALIDPARAMS;
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_set_capture_state
*
* This routine takes the current control word definition ( stored in locals )
* adds in the specified state, and writes the control word.
*--------------------------------------------------------------------------*/
int
vip_set_capture_state(unsigned long state)
{
unsigned long vip_control1, vip_control3;
/* UPDATE THE CURRENT CAPTURE MODE */
vip_control1 = READ_VIP32(VIP_CONTROL1);
vip_control3 = READ_VIP32(VIP_CONTROL3);
vip_control1 &= ~VIP_CONTROL1_RUNMODE_MASK;
vip_control1 |= (state << VIP_CONTROL1_RUNMODE_SHIFT);
WRITE_VIP32(VIP_CONTROL1, vip_control1);
if (state >= VIP_STARTCAPTUREATNEXTLINE) {
/* WHACK VIP RESET
* The VIP can get confused when switching between capture settings,
* such as between linear and planar. We will thus whack VIP reset
* when enabling capture to ensure a pristine VIP state.
*/
WRITE_VIP32(VIP_CONTROL1, vip_control1 | VIP_CONTROL1_RESET);
WRITE_VIP32(VIP_CONTROL1, vip_control1 & ~VIP_CONTROL1_RESET);
WRITE_VIP32(VIP_CONTROL3, vip_control3 | VIP_CONTROL3_FIFO_RESET);
}
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_terminate
*
* This routine stops VIP capture and resets the VIP internal state.
*--------------------------------------------------------------------------*/
int
vip_terminate(void)
{
unsigned long timeout = 50000;
/* DISABLE AND CLEAR ALL VIP INTERRUPTS */
WRITE_VIP32(VIP_INTERRUPT, VIP_ALL_INTERRUPTS | (VIP_ALL_INTERRUPTS >> 16));
/* DISABLE VIP CAPTURE */
/* We will try to let the VIP FIFO flush before shutting it down. */
WRITE_VIP32(VIP_CONTROL1, 0);
while (timeout) {
timeout--;
if (READ_VIP32(VIP_STATUS) & VIP_STATUS_WRITES_COMPLETE)
break;
}
/* RESET THE HARDWARE REGISTERS */
/* Note that we enable VIP reset to allow clock gating to lower VIP */
/* power consumption. */
WRITE_VIP32(VIP_CONTROL1, VIP_CONTROL1_RESET);
WRITE_VIP32(VIP_CONTROL3, VIP_CONTROL3_FIFO_RESET);
WRITE_VIP32(VIP_CONTROL2, 0);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_configure_fifo
*
* This routine sets the desired threshold or flush for the specified fifo.
*--------------------------------------------------------------------------*/
int
vip_configure_fifo(unsigned long fifo_type, unsigned long fifo_size)
{
unsigned long vip_control1, vip_control2;
vip_control1 = READ_VIP32(VIP_CONTROL1);
vip_control2 = READ_VIP32(VIP_CONTROL2);
switch (fifo_type) {
case VIP_VIDEOTHRESHOLD:
vip_control2 &= ~VIP_CONTROL2_VIDTH_MASK;
vip_control2 |=
(fifo_size << VIP_CONTROL2_VIDTH_SHIFT) & VIP_CONTROL2_VIDTH_MASK;
break;
case VIP_ANCILLARYTHRESHOLD:
vip_control2 &= ~VIP_CONTROL2_ANCTH_MASK;
vip_control2 |=
(fifo_size << VIP_CONTROL2_ANCTH_SHIFT) & VIP_CONTROL2_ANCTH_MASK;
break;
case VIP_VIDEOFLUSH:
vip_control1 &= ~VIP_CONTROL1_VID_FF_MASK;
vip_control1 |=
((fifo_size >> 2) << VIP_CONTROL1_VID_FF_SHIFT) &
VIP_CONTROL1_VID_FF_MASK;
break;
case VIP_ANCILLARYFLUSH:
vip_control1 &= ~VIP_CONTROL1_ANC_FF_MASK;
vip_control1 |=
((fifo_size >> 2) << VIP_CONTROL1_ANC_FF_SHIFT) &
VIP_CONTROL1_ANC_FF_MASK;
break;
default:
return CIM_STATUS_INVALIDPARAMS;
}
WRITE_VIP32(VIP_CONTROL1, vip_control1);
WRITE_VIP32(VIP_CONTROL2, vip_control2);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_set_interrupt_enable
*
* This routine accepts a mask of interrupts to be enabled/disabled and
* an enable flag.
*
* For each mask match, the interrupt will be enabled or disabled based on
* enable
*--------------------------------------------------------------------------*/
int
vip_set_interrupt_enable(unsigned long mask, int enable)
{
/* CHECK IF ANY VALID INTERRUPTS ARE BEING CHANGED */
if (mask & VIP_ALL_INTERRUPTS) {
unsigned long int_enable = READ_VIP32(VIP_INTERRUPT) & 0xFFFF;
/* SET OR CLEAR THE MASK BITS */
/* Note that the upper 16-bits of the register are 0 after this */
/* operation. This prevents us from indadvertently clearing a */
/* pending interrupt by enabling/disabling another one. */
if (enable)
int_enable &= ~(mask >> 16);
else
int_enable |= (mask >> 16);
WRITE_VIP32(VIP_INTERRUPT, int_enable);
}
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_set_vsync_error
*
* This routine defines a region that is used to determine if the vsync is
* within an acceptable range. This definition is accomplished using
* a count and a vertical window. The count specifies the exact number
* of clocks expected for one field. The window parameters specify the number
* of clocks variation allowed before and after the expected vsync. For
* example, if vertical_count is 1000, window_before is 5 and window_after
* is 12, VSync will be considered valid if it occurs between 995 and 1012
* clocks after the last VSync. The total window size (window_before +
* window_after) cannot exceed 255.
*--------------------------------------------------------------------------*/
int
vip_set_vsync_error(unsigned long vertical_count, unsigned long window_before,
unsigned long window_after, int enable)
{
unsigned long vip_control2 = READ_VIP32(VIP_CONTROL2);
unsigned long temp;
if (enable) {
/* CREATE THE VERTICAL WINDOW
* The VIP uses two counters. The first counter defines the minimum
* clock count before a valid VSync can occur. The second counter
* starts after the first completes and defines the acceptable
* region of variation.
*/
temp = ((window_before +
window_after) << VIP_VSYNC_ERR_WINDOW_SHIFT) &
VIP_VSYNC_ERR_WINDOW_MASK;
temp |= (vertical_count - window_before) & VIP_VSYNC_ERR_COUNT_MASK;
vip_control2 |= VIP_CONTROL2_VERTERROR_ENABLE;
WRITE_VIP32(VIP_VSYNC_ERR_COUNT, temp);
}
else {
vip_control2 &= ~VIP_CONTROL2_VERTERROR_ENABLE;
}
WRITE_VIP32(VIP_CONTROL2, vip_control2);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_max_address_enable
*
* This routine specifies the maximum address to which the the hardware should
* write during data storage. If this value is exceeded an error is generated,
* (this may be monitored using the appropriate interrupt flags - see
* vip_set_interrupt_enable)
*--------------------------------------------------------------------------*/
int
vip_max_address_enable(unsigned long max_address, int enable)
{
unsigned long vip_control2 = READ_VIP32(VIP_CONTROL2);
if (enable) {
/* ENABLE THE CONTROL BIT */
vip_control2 |= VIP_CONTROL2_ADD_ERROR_ENABLE;
WRITE_VIP32(VIP_MAX_ADDRESS, max_address & VIP_MAXADDR_MASK);
}
else {
/* DISABLE DETECTION */
vip_control2 &= ~VIP_CONTROL2_ADD_ERROR_ENABLE;
}
WRITE_VIP32(VIP_CONTROL2, vip_control2);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_set_loopback_enable
*
* This routine enables/disables internal loopback functionality. When
* loopback is enabled, the VOP outputs are rerouted to the VIP inputs
* internal to the chip. No loopback connector is required.
*--------------------------------------------------------------------------*/
int
vip_set_loopback_enable(int enable)
{
unsigned long vip_control2 = READ_VIP32(VIP_CONTROL2);
if (enable)
vip_control2 |= VIP_CONTROL2_LOOPBACK_ENABLE;
else
vip_control2 &= ~VIP_CONTROL2_LOOPBACK_ENABLE;
WRITE_VIP32(VIP_CONTROL2, vip_control2);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_configure_genlock
*
* This routine configures genlock functionality.
*---------------------------------------------------------------------------*/
int
vip_configure_genlock(VIPGENLOCKBUFFER * buffer)
{
unsigned long vip_control1, vip_control2;
unsigned long unlock, genlk_ctl;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
unlock = READ_REG32(DC3_UNLOCK);
genlk_ctl = READ_REG32(DC3_GENLK_CTL);
vip_control1 = READ_VIP32(VIP_CONTROL1);
vip_control2 = READ_VIP32(VIP_CONTROL2);
/* UPDATE VIDEO DETECTION */
/* These flags are used to indicate the ways in which the VIP signal */
/* can be considered 'lost'. */
vip_control1 &= ~VIP_CONTROL1_VDE_FF_MASK;
vip_control2 &= ~(VIP_CONTROL2_FIELD2VG_MASK | VIP_CONTROL2_SYNC2VG_MASK);
vip_control1 |= buffer->vip_signal_loss;
/* UPDATE FIELD AND VSYNC INFORMATION */
/* These flags control how and when the even/odd field and Vsync */
/* information is communicated to the VG. */
vip_control2 |= buffer->field_to_vg;
vip_control2 |= buffer->vsync_to_vg;
/* ENABLE OR DISABLE GENLOCK TIMEOUT */
/* Enabling genlock timeout allows the VG to revert to its own sync */
/* timings when the VIP input is lost. Note that the VIP will not */
/* know the signal is lost unless the appropriate error detection */
/* flags have been enabled inside vip_initialize. */
if (buffer->enable_timeout)
genlk_ctl |= DC3_GC_GENLOCK_TO_ENABLE;
else
genlk_ctl &= ~DC3_GC_GENLOCK_TO_ENABLE;
genlk_ctl &= ~DC3_GC_GENLOCK_SKEW_MASK;
genlk_ctl |= buffer->genlock_skew & DC3_GC_GENLOCK_SKEW_MASK;
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_GENLK_CTL, genlk_ctl);
WRITE_VIP32(VIP_CONTROL1, vip_control1);
WRITE_VIP32(VIP_CONTROL2, vip_control2);
WRITE_REG32(DC3_UNLOCK, unlock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_set_genlock_enable
*
* This routine enables/disables genlock inside the VG.
*--------------------------------------------------------------------------*/
int
vip_set_genlock_enable(int enable)
{
unsigned long unlock, temp;
unlock = READ_REG32(DC3_UNLOCK);
temp = READ_REG32(DC3_GENLK_CTL);
if (enable)
temp |= DC3_GC_GENLOCK_ENABLE;
else
temp &= ~DC3_GC_GENLOCK_ENABLE;
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_GENLK_CTL, temp);
WRITE_REG32(DC3_UNLOCK, unlock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_set_power_characteristics
*
* This routine takes a VIPPOWERBUFFER structure, and selectively sets the
* GeodeLink power and/or Vip clock power states.
*--------------------------------------------------------------------------*/
int
vip_set_power_characteristics(VIPPOWERBUFFER * buffer)
{
Q_WORD q_word;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
q_word.low = q_word.high = 0;
/* ENABLE GEODELINK CLOCK GATING */
if (buffer->glink_clock_mode)
q_word.low |= VIP_MSR_POWER_GLINK;
/* ENABLE VIP CLOCK GATING */
if (buffer->vip_clock_mode)
q_word.low |= VIP_MSR_POWER_CLOCK;
/* WRITE THE NEW VALUE */
msr_write64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_PM, &q_word);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_set_priority_characteristics
*
* This routine programs the VIP GeodeLink priority characteristics
*--------------------------------------------------------------------------*/
int
vip_set_priority_characteristics(VIPPRIORITYBUFFER * buffer)
{
Q_WORD q_word;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
q_word.low = q_word.high = 0;
q_word.low |= (buffer->secondary <<
VIP_MSR_MCR_SECOND_PRIORITY_SHIFT) &
VIP_MSR_MCR_SECOND_PRIORITY_MASK;
q_word.low |=
(buffer->
primary << VIP_MSR_MCR_PRIMARY_PRIORITY_SHIFT) &
VIP_MSR_MCR_PRIMARY_PRIORITY_MASK;
q_word.low |= (buffer->pid << VIP_MSR_MCR_PID_SHIFT) & VIP_MSR_MCR_PID_MASK;
msr_write64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_CONFIG, &q_word);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_set_debug_characteristics
*
* This routine configures the debug data that is exposed over the diag bus.
*--------------------------------------------------------------------------*/
int
vip_set_debug_characteristics(VIPDEBUGBUFFER * buffer)
{
Q_WORD q_word;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
q_word.low = q_word.high = 0;
q_word.high |= (buffer->bist << VIP_MSR_DIAG_BIST_SHIFT) &
VIP_MSR_DIAG_BIST_WMASK;
q_word.low |= (buffer->enable_upper ? VIP_MSR_DIAG_MSB_ENABLE : 0x00000000);
q_word.low |= (buffer->select_upper << VIP_MSR_DIAG_SEL_UPPER_SHIFT) &
VIP_MSR_DIAG_SEL_UPPER_MASK;
q_word.low |= (buffer->enable_lower ? VIP_MSR_DIAG_LSB_ENABLE : 0x00000000);
q_word.low |= (buffer->select_lower << VIP_MSR_DIAG_SEL_LOWER_SHIFT) &
VIP_MSR_DIAG_SEL_LOWER_MASK;
msr_write64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_DIAG, &q_word);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_configure_pages
*
* This routine sets the number of pages, and their offset from each other.
*--------------------------------------------------------------------------*/
int
vip_configure_pages(int page_count, unsigned long page_offset)
{
unsigned long vip_control2 = READ_VIP32(VIP_CONTROL2);
/* SET THE NEW PAGE COUNT */
vip_control2 &= ~VIP_CONTROL2_PAGECNT_MASK;
vip_control2 |= (page_count << VIP_CONTROL2_PAGECNT_SHIFT) &
VIP_CONTROL2_PAGECNT_MASK;
/* WRITE THE PAGE OFFSET */
WRITE_VIP32(VIP_CONTROL2, vip_control2);
WRITE_VIP32(VIP_PAGE_OFFSET, page_offset);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_set_interrupt_line
*
* This routine sets the line at which a line interrupt should be generated.
*--------------------------------------------------------------------------*/
int
vip_set_interrupt_line(int line)
{
WRITE_VIP32(VIP_CURRENT_TARGET,
(line << VIP_CTARGET_TLINE_SHIFT) & VIP_CTARGET_TLINE_MASK);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_reset
*
* This routine does a one-shot enable of the VIP hardware. It is useful
* for handling unrecoverable VIP errors.
*--------------------------------------------------------------------------*/
int
vip_reset(void)
{
unsigned long vip_control1, vip_control3;
/* INVERT THE PAUSE BIT */
vip_control1 = READ_VIP32(VIP_CONTROL1);
vip_control3 = READ_VIP32(VIP_CONTROL3);
WRITE_VIP32(VIP_CONTROL1, vip_control1 | VIP_CONTROL1_RESET);
WRITE_VIP32(VIP_CONTROL1, vip_control1 & ~VIP_CONTROL1_RESET);
WRITE_VIP32(VIP_CONTROL3, vip_control3 | VIP_CONTROL3_FIFO_RESET);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_set_subwindow_enable
*
* This routine turns on SubWindow capture, that is a portion of the incoming
* signal is captured rather than the entire frame. The window always has
* the same width as the frame, only the vertical component can be
* modified.
*--------------------------------------------------------------------------*/
int
vip_set_subwindow_enable(VIPSUBWINDOWBUFFER * buffer)
{
unsigned long vip_control2;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
vip_control2 = READ_VIP32(VIP_CONTROL2);
if (buffer->enable) {
/* WRITE THE WINDOW VALUE */
WRITE_VIP32(VIP_VERTICAL_START_STOP, ((buffer->stop <<
VIP_VSTART_VERTEND_SHIFT) &
VIP_VSTART_VERTEND_MASK) |
((buffer->
start << VIP_VSTART_VERTSTART_SHIFT) &
VIP_VSTART_VERTSTART_MASK));
/* ENABLE IN THE CONTROL REGISTER */
vip_control2 |= VIP_CONTROL2_SWC_ENABLE;
}
else {
/* DISABLE SUBWINDOW CAPTURE IN THE CONTROL REGISTER */
vip_control2 &= ~VIP_CONTROL2_SWC_ENABLE;
}
WRITE_VIP32(VIP_CONTROL2, vip_control2);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_reset_interrupt_state
*
* This routine resets the state of one or more interrupts.
*--------------------------------------------------------------------------*/
int
vip_reset_interrupt_state(unsigned long interrupt_mask)
{
unsigned long temp;
temp = READ_VIP32(VIP_INTERRUPT);
WRITE_VIP32(VIP_INTERRUPT, temp | (interrupt_mask & VIP_ALL_INTERRUPTS));
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_save_state
*
* This routine saves the necessary register contents in order to restore
* at a later point to the same state.
*
* NOTE: Capture state is forced to OFF in this routine
*--------------------------------------------------------------------------*/
int
vip_save_state(VIPSTATEBUFFER * save_buffer)
{
if (!save_buffer)
return CIM_STATUS_INVALIDPARAMS;
/* FORCE CAPTURE TO BE DISABLED */
vip_set_capture_state(VIP_STOPCAPTURE);
/* READ AND SAVE THE REGISTER CONTENTS */
save_buffer->control1 = READ_VIP32(VIP_CONTROL1);
save_buffer->control2 = READ_VIP32(VIP_CONTROL2);
save_buffer->vip_int = READ_VIP32(VIP_INTERRUPT);
save_buffer->current_target = READ_VIP32(VIP_CURRENT_TARGET);
save_buffer->max_address = READ_VIP32(VIP_MAX_ADDRESS);
save_buffer->taska_evenbase = READ_VIP32(VIP_TASKA_VID_EVEN_BASE);
save_buffer->taska_oddbase = READ_VIP32(VIP_TASKA_VID_ODD_BASE);
save_buffer->taska_vbi_evenbase = READ_VIP32(VIP_TASKA_VBI_EVEN_BASE);
save_buffer->taska_vbi_oddbase = READ_VIP32(VIP_TASKA_VBI_ODD_BASE);
save_buffer->taska_data_pitch = READ_VIP32(VIP_TASKA_VID_PITCH);
save_buffer->control3 = READ_VIP32(VIP_CONTROL3);
save_buffer->taska_v_oddoffset = READ_VIP32(VIP_TASKA_U_OFFSET);
save_buffer->taska_u_oddoffset = READ_VIP32(VIP_TASKA_V_OFFSET);
save_buffer->taskb_evenbase = READ_VIP32(VIP_TASKB_VID_EVEN_BASE);
save_buffer->taskb_oddbase = READ_VIP32(VIP_TASKB_VID_ODD_BASE);
save_buffer->taskb_vbi_evenbase = READ_VIP32(VIP_TASKB_VBI_EVEN_BASE);
save_buffer->taskb_vbi_oddbase = READ_VIP32(VIP_TASKB_VBI_ODD_BASE);
save_buffer->taskb_pitch = READ_VIP32(VIP_TASKB_VID_PITCH);
save_buffer->taskb_voffset = READ_VIP32(VIP_TASKB_U_OFFSET);
save_buffer->taskb_uoffset = READ_VIP32(VIP_TASKB_V_OFFSET);
save_buffer->msg1_base = READ_VIP32(VIP_ANC_MSG1_BASE);
save_buffer->msg2_base = READ_VIP32(VIP_ANC_MSG2_BASE);
save_buffer->msg_size = READ_VIP32(VIP_ANC_MSG_SIZE);
save_buffer->page_offset = READ_VIP32(VIP_PAGE_OFFSET);
save_buffer->vert_start_stop = READ_VIP32(VIP_VERTICAL_START_STOP);
save_buffer->vsync_err_count = READ_VIP32(VIP_VSYNC_ERR_COUNT);
save_buffer->taska_u_evenoffset = READ_VIP32(VIP_TASKA_U_EVEN_OFFSET);
save_buffer->taska_v_evenoffset = READ_VIP32(VIP_TASKA_V_EVEN_OFFSET);
/* READ ALL VIP MSRS */
msr_read64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_CONFIG,
&(save_buffer->msr_config));
msr_read64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_SMI,
&(save_buffer->msr_smi));
msr_read64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_PM,
&(save_buffer->msr_pm));
msr_read64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_DIAG,
&(save_buffer->msr_diag));
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_restore_state
*
* This routine restores the state of the vip registers - which were
* previously saved using vip_save_state.
*--------------------------------------------------------------------------*/
int
vip_restore_state(VIPSTATEBUFFER * restore_buffer)
{
if (!restore_buffer)
return CIM_STATUS_OK;
/* RESTORE THE REGISTERS */
WRITE_VIP32(VIP_CURRENT_TARGET, restore_buffer->current_target);
WRITE_VIP32(VIP_MAX_ADDRESS, restore_buffer->max_address);
WRITE_VIP32(VIP_TASKA_VID_EVEN_BASE, restore_buffer->taska_evenbase);
WRITE_VIP32(VIP_TASKA_VID_ODD_BASE, restore_buffer->taska_oddbase);
WRITE_VIP32(VIP_TASKA_VBI_EVEN_BASE, restore_buffer->taska_vbi_evenbase);
WRITE_VIP32(VIP_TASKA_VBI_ODD_BASE, restore_buffer->taska_vbi_oddbase);
WRITE_VIP32(VIP_TASKA_VID_PITCH, restore_buffer->taska_data_pitch);
WRITE_VIP32(VIP_CONTROL3, restore_buffer->control3);
WRITE_VIP32(VIP_TASKA_U_OFFSET, restore_buffer->taska_v_oddoffset);
WRITE_VIP32(VIP_TASKA_V_OFFSET, restore_buffer->taska_u_oddoffset);
WRITE_VIP32(VIP_TASKB_VID_EVEN_BASE, restore_buffer->taskb_evenbase);
WRITE_VIP32(VIP_TASKB_VID_ODD_BASE, restore_buffer->taskb_oddbase);
WRITE_VIP32(VIP_TASKB_VBI_EVEN_BASE, restore_buffer->taskb_vbi_evenbase);
WRITE_VIP32(VIP_TASKB_VBI_ODD_BASE, restore_buffer->taskb_vbi_oddbase);
WRITE_VIP32(VIP_TASKB_VID_PITCH, restore_buffer->taskb_pitch);
WRITE_VIP32(VIP_TASKB_U_OFFSET, restore_buffer->taskb_voffset);
WRITE_VIP32(VIP_TASKB_V_OFFSET, restore_buffer->taskb_uoffset);
WRITE_VIP32(VIP_ANC_MSG1_BASE, restore_buffer->msg1_base);
WRITE_VIP32(VIP_ANC_MSG2_BASE, restore_buffer->msg2_base);
WRITE_VIP32(VIP_ANC_MSG_SIZE, restore_buffer->msg_size);
WRITE_VIP32(VIP_PAGE_OFFSET, restore_buffer->page_offset);
WRITE_VIP32(VIP_VERTICAL_START_STOP, restore_buffer->vert_start_stop);
WRITE_VIP32(VIP_VSYNC_ERR_COUNT, restore_buffer->vsync_err_count);
WRITE_VIP32(VIP_TASKA_U_EVEN_OFFSET, restore_buffer->taska_u_evenoffset);
WRITE_VIP32(VIP_TASKA_V_EVEN_OFFSET, restore_buffer->taska_v_evenoffset);
/* RESTORE THE VIP MSRS */
msr_write64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_CONFIG,
&(restore_buffer->msr_config));
msr_write64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_SMI,
&(restore_buffer->msr_smi));
msr_write64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_PM,
&(restore_buffer->msr_pm));
msr_write64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_DIAG,
&(restore_buffer->msr_diag));
/* RESTORE THE CONTROL WORDS LAST */
WRITE_VIP32(VIP_CONTROL1, restore_buffer->control1);
WRITE_VIP32(VIP_CONTROL2, restore_buffer->control2);
WRITE_VIP32(VIP_CONTROL3, restore_buffer->control3);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_get_interrupt_state
*
* This routine returns the current interrupt state of the system. The
* rv can be tested with the following flags to determine if the appropriate
* event has occured.
*--------------------------------------------------------------------------*/
unsigned long
vip_get_interrupt_state(void)
{
unsigned long interrupt_mask = READ_VIP32(VIP_INTERRUPT);
return (~(interrupt_mask << 16) & interrupt_mask & VIP_ALL_INTERRUPTS);
}
/*---------------------------------------------------------------------------
* vip_test_genlock_active
*
* This routine reads the live status of the genlock connection between the
* VIP and VG blocks.
*--------------------------------------------------------------------------*/
int
vip_test_genlock_active(void)
{
if (READ_REG32(DC3_GENLK_CTL) & DC3_GC_GENLK_ACTIVE)
return 1;
return 0;
}
/*---------------------------------------------------------------------------
* vip_test_signal_status
*
* This routine reads the live signal status coming into the VIP block.
*--------------------------------------------------------------------------*/
int
vip_test_signal_status(void)
{
if (READ_REG32(DC3_GENLK_CTL) & DC3_GC_VIP_VID_OK)
return 1;
return 0;
}
/*---------------------------------------------------------------------------
* vip_get_current_field
*
* This routine returns the current field being received.
*--------------------------------------------------------------------------*/
unsigned long
vip_get_current_field(void)
{
if (READ_VIP32(VIP_STATUS) & VIP_STATUS_FIELD)
return VIP_EVEN_FIELD;
return VIP_ODD_FIELD;
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* CIMARRON VIP READ ROUTINES
* These routines are included for use in diagnostics or when debugging. They
* can be optionally excluded from a project.
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#if CIMARRON_INCLUDE_VIP_READ_ROUTINES
/*---------------------------------------------------------------------------
* vip_get_current_mode
*
* This routine reads the current VIP operating mode.
*--------------------------------------------------------------------------*/
int
vip_get_current_mode(VIPSETMODEBUFFER * buffer)
{
unsigned long vip_control1, vip_control2, vip_control3;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
vip_control1 = READ_VIP32(VIP_CONTROL1);
vip_control2 = READ_VIP32(VIP_CONTROL2);
vip_control3 = READ_VIP32(VIP_CONTROL3);
/* READ CURRENT OPERATING MODE AND ENABLES */
buffer->stream_enables = vip_control1 & VIP_ENABLE_ALL;
buffer->operating_mode = vip_control1 & VIP_CONTROL1_MODE_MASK;
/* READ CURRENT PLANAR CAPTURE SETTINGS */
buffer->flags = 0;
buffer->planar_capture = 0;
if (vip_control1 & VIP_CONTROL1_PLANAR) {
buffer->flags |= VIP_MODEFLAG_PLANARCAPTURE;
if (vip_control1 & VIP_CONTROL1_DISABLE_DECIMATION) {
if (vip_control3 & VIP_CONTROL3_DECIMATE_EVEN)
buffer->planar_capture = VIP_420CAPTURE_ALTERNATINGFIELDS;
else
buffer->planar_capture = VIP_420CAPTURE_EVERYLINE;
}
else
buffer->planar_capture = VIP_420CAPTURE_ALTERNATINGLINES;
}
/* READ MISCELLANEOUS FLAGS */
if (vip_control1 & VIP_CONTROL1_NON_INTERLACED)
buffer->flags |= VIP_MODEFLAG_PROGRESSIVE;
if (vip_control3 & VIP_CONTROL3_BASE_UPDATE)
buffer->flags |= VIP_MODEFLAG_TOGGLEEACHFIELD;
if (vip_control2 & VIP_CONTROL2_INVERT_POLARITY)
buffer->flags |= VIP_MODEFLAG_INVERTPOLARITY;
if (vip_control1 & VIP_CONTROL1_MSG_STRM_CTRL)
buffer->flags |= VIP_MODEFLAG_FLIPMESSAGEWHENFULL;
if (vip_control2 & VIP_CONTROL2_REPEAT_ENABLE)
buffer->flags |= VIP_MODEFLAG_ENABLEREPEATFLAG;
if (vip_control3 & VIP_CONTROL3_TASK_POLARITY)
buffer->flags |= VIP_MODEFLAG_INVERTTASKPOLARITY;
if (vip_control1 & VIP_CONTROL1_DISABLE_ZERO_DETECT)
buffer->flags |= VIP_MODEFLAG_DISABLEZERODETECT;
if (vip_control2 & VIP_CONTROL2_ANC10)
buffer->flags |= VIP_MODEFLAG_10BITANCILLARY;
/* READ THE CURRENT VIP 601 SETTINGS */
vip_get_601_configuration(&buffer->vip601_settings);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_get_601_configuration
*
* This routine returns the current 601 configuration information.
*--------------------------------------------------------------------------*/
int
vip_get_601_configuration(VIP_601PARAMS * buffer)
{
unsigned long vip_control3, vip_control1;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
vip_control1 = READ_VIP32(VIP_CONTROL3);
vip_control3 = READ_VIP32(VIP_CONTROL3);
buffer->flags = 0;
if (vip_control3 & VIP_CONTROL3_VSYNC_POLARITY)
buffer->flags |= VIP_MODEFLAG_VSYNCACTIVEHIGH;
if (vip_control3 & VIP_CONTROL3_HSYNC_POLARITY)
buffer->flags |= VIP_MODEFLAG_HSYNCACTIVEHIGH;
buffer->horz_start = READ_VIP32(VIP_601_HORZ_START);
buffer->vbi_start = READ_VIP32(VIP_601_VBI_START);
buffer->vbi_height = READ_VIP32(VIP_601_VBI_END) - buffer->vbi_start + 1;
buffer->vert_start_even = READ_VIP32(VIP_601_EVEN_START_STOP) & 0xFFFF;
buffer->even_height = (READ_VIP32(VIP_601_EVEN_START_STOP) >> 16) -
buffer->vert_start_even + 1;
buffer->vert_start_odd = READ_VIP32(VIP_601_ODD_START_STOP) & 0xFFFF;
buffer->odd_height = (READ_VIP32(VIP_601_ODD_START_STOP) >> 16) -
buffer->vert_start_odd + 1;
buffer->odd_detect_start = READ_VIP32(VIP_ODD_FIELD_DETECT) & 0xFFFF;
buffer->odd_detect_end = READ_VIP32(VIP_ODD_FIELD_DETECT) >> 16;
/* SPECIAL CASE FOR HORIZONTAL DATA
* 601 horizontal parameters are based on the number of clocks and not
* the number of pixels.
*/
if ((vip_control1 & VIP_CONTROL1_MODE_MASK) == VIP_MODE_16BIT601)
buffer->width = (READ_VIP32(VIP_601_HORZ_END) -
buffer->horz_start - 3) >> 1;
else
buffer->width = (READ_VIP32(VIP_601_HORZ_END) - buffer->horz_start - 3);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_get_buffer_configuration
*
* This routine reads the current buffer configuration for Task A, Task B,
* ancillary or message data. The current_buffer member indicates which
* array index should hold the new values for Task A or Task B data.
*--------------------------------------------------------------------------*/
int
vip_get_buffer_configuration(int buffer_type, VIPINPUTBUFFER * buffer)
{
unsigned long cur_buffer = buffer->current_buffer;
VIPINPUTBUFFER_ADDR *offsets;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
if (buffer_type == VIP_BUFFER_A) {
offsets = &buffer->offsets[VIP_BUFFER_TASK_A];
/* READ VIDEO PITCH */
offsets->y_pitch = READ_VIP32(VIP_TASKA_VID_PITCH) & 0xFFFF;
offsets->uv_pitch = READ_VIP32(VIP_TASKA_VID_PITCH) >> 16;
/* READ BASE OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_INVERTPOLARITY) {
offsets->even_base[cur_buffer] = READ_VIP32(VIP_TASKA_VID_ODD_BASE);
offsets->odd_base[cur_buffer] = READ_VIP32(VIP_TASKA_VID_EVEN_BASE);
if (buffer->flags & VIP_INPUTFLAG_VBI) {
offsets->vbi_even_base = READ_VIP32(VIP_TASKA_VBI_ODD_BASE);
offsets->vbi_odd_base = READ_VIP32(VIP_TASKA_VBI_EVEN_BASE);
}
}
else {
offsets->even_base[cur_buffer] =
READ_VIP32(VIP_TASKA_VID_EVEN_BASE);
offsets->odd_base[cur_buffer] = READ_VIP32(VIP_TASKA_VID_ODD_BASE);
if (buffer->flags & VIP_INPUTFLAG_VBI) {
offsets->vbi_even_base = READ_VIP32(VIP_TASKA_VBI_EVEN_BASE);
offsets->vbi_odd_base = READ_VIP32(VIP_TASKA_VBI_ODD_BASE);
}
}
/* READ 4:2:0 OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_PLANAR) {
offsets->odd_uoffset = READ_VIP32(VIP_TASKA_U_OFFSET);
offsets->odd_voffset = READ_VIP32(VIP_TASKA_V_OFFSET);
offsets->even_uoffset = READ_VIP32(VIP_TASKA_U_EVEN_OFFSET);
offsets->even_voffset = READ_VIP32(VIP_TASKA_V_EVEN_OFFSET);
}
}
else if (buffer_type == VIP_BUFFER_B) {
offsets = &buffer->offsets[VIP_BUFFER_TASK_B];
/* READ VIDEO PITCH */
offsets->y_pitch = READ_VIP32(VIP_TASKB_VID_PITCH) & 0xFFFF;
offsets->uv_pitch = READ_VIP32(VIP_TASKB_VID_PITCH) >> 16;
/* READ BASE OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_INVERTPOLARITY) {
offsets->even_base[cur_buffer] = READ_VIP32(VIP_TASKB_VID_ODD_BASE);
offsets->odd_base[cur_buffer] = READ_VIP32(VIP_TASKB_VID_EVEN_BASE);
if (buffer->flags & VIP_INPUTFLAG_VBI) {
offsets->vbi_even_base = READ_VIP32(VIP_TASKB_VBI_ODD_BASE);
offsets->vbi_odd_base = READ_VIP32(VIP_TASKB_VBI_EVEN_BASE);
}
}
else {
offsets->even_base[cur_buffer] =
READ_VIP32(VIP_TASKB_VID_EVEN_BASE);
offsets->odd_base[cur_buffer] = READ_VIP32(VIP_TASKB_VID_ODD_BASE);
if (buffer->flags & VIP_INPUTFLAG_VBI) {
offsets->vbi_even_base = READ_VIP32(VIP_TASKB_VBI_EVEN_BASE);
offsets->vbi_odd_base = READ_VIP32(VIP_TASKB_VBI_ODD_BASE);
}
}
/* READ 4:2:0 OFFSETS */
if (buffer->flags & VIP_INPUTFLAG_PLANAR) {
offsets->odd_uoffset = READ_VIP32(VIP_TASKB_U_OFFSET);
offsets->odd_voffset = READ_VIP32(VIP_TASKB_V_OFFSET);
}
}
else if (buffer_type == VIP_BUFFER_ANC || buffer_type == VIP_BUFFER_MSG) {
buffer->ancillaryData.msg1_base = READ_VIP32(VIP_ANC_MSG1_BASE);
buffer->ancillaryData.msg2_base = READ_VIP32(VIP_ANC_MSG2_BASE);
buffer->ancillaryData.msg_size = READ_VIP32(VIP_ANC_MSG_SIZE);
}
else {
return CIM_STATUS_INVALIDPARAMS;
}
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_get_genlock_configuration
*
* This routine reads the current genlock configuration.
*--------------------------------------------------------------------------*/
int
vip_get_genlock_configuration(VIPGENLOCKBUFFER * buffer)
{
unsigned long vip_control1, vip_control2;
unsigned long genlk_ctl;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
genlk_ctl = READ_REG32(DC3_GENLK_CTL);
vip_control1 = READ_VIP32(VIP_CONTROL1);
vip_control2 = READ_VIP32(VIP_CONTROL2);
/* READ ERROR DETECTION, CURRENT FIELD AND CURRENT VSYNC
* These flags are used to indicate the ways in which the VIP signal can
* be considered 'lost'.
*/
buffer->vip_signal_loss = vip_control1 & VIP_CONTROL1_VDE_FF_MASK;
buffer->field_to_vg = vip_control2 & VIP_CONTROL2_FIELD2VG_MASK;
buffer->vsync_to_vg = vip_control2 & VIP_CONTROL2_SYNC2VG_MASK;
/* GENLOCK TIMEOUT ENABLE */
buffer->enable_timeout = 0;
if (genlk_ctl & DC3_GC_GENLOCK_TO_ENABLE)
buffer->enable_timeout = 1;
/* GENLOCK SKEW */
buffer->genlock_skew = genlk_ctl & DC3_GC_GENLOCK_SKEW_MASK;
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_get_genlock_enable
*
* This routine returns the current enable status of genlock in the VG.
*--------------------------------------------------------------------------*/
int
vip_get_genlock_enable(void)
{
if (READ_REG32(DC3_GENLK_CTL) & DC3_GC_GENLOCK_ENABLE)
return 1;
return 0;
}
/*---------------------------------------------------------------------------
* vip_is_buffer_update_latched
*
* This routine indicates whether changes to the VIP offsets have been
* latched by the hardware.
*--------------------------------------------------------------------------*/
int
vip_is_buffer_update_latched(void)
{
return (!(READ_VIP32(VIP_STATUS) & VIP_STATUS_BASEREG_NOTUPDT));
}
/*---------------------------------------------------------------------------
* vip_get_capture_state
*
* This routine reads the current capture status of the VIP hardware.
*--------------------------------------------------------------------------*/
unsigned long
vip_get_capture_state(void)
{
return ((READ_VIP32(VIP_CONTROL1) & VIP_CONTROL1_RUNMODE_MASK) >>
VIP_CONTROL1_RUNMODE_SHIFT);
}
/*---------------------------------------------------------------------------
* vip_get_current_line
*
* This routine returns the current line that is being processed.
*--------------------------------------------------------------------------*/
unsigned long
vip_get_current_line(void)
{
return (READ_VIP32(VIP_CURRENT_TARGET) & VIP_CTARGET_CLINE_MASK);
}
/*---------------------------------------------------------------------------
* vip_read_fifo
*
* This routine reads from the specified fifo address. As the fifo access
* enable should be disabled when running in normal vip mode, this routine
* enables and disables access around the read.
* DIAGNOSTIC USE ONLY
*--------------------------------------------------------------------------*/
unsigned long
vip_read_fifo(unsigned long dwFifoAddress)
{
unsigned long fifo_data;
/* ENABLE FIFO ACCESS */
vip_enable_fifo_access(1);
/* NOW READ THE DATA */
WRITE_VIP32(VIP_FIFO_ADDRESS, dwFifoAddress);
fifo_data = READ_VIP32(VIP_FIFO_DATA);
/* DISABLE FIFO ACCESS */
vip_enable_fifo_access(0);
return fifo_data;
}
/*---------------------------------------------------------------------------
* vip_write_fifo
*
* SYNOPSIS:
* This routine writes to the specified fifo address. As the fifo access
* enable should be disabled when running in normal vip mode, this routine
* enables and disables access around the write.
* DIAGNOSTIC USE ONLY
*--------------------------------------------------------------------------*/
int
vip_write_fifo(unsigned long dwFifoAddress, unsigned long dwFifoData)
{
/* ENABLE FIFO ACCESS */
vip_enable_fifo_access(1);
/* WRITE THE FIFO DATA */
WRITE_VIP32(VIP_FIFO_ADDRESS, dwFifoAddress);
WRITE_VIP32(VIP_FIFO_DATA, dwFifoData);
/* DISABLE FIFO ACCESS */
vip_enable_fifo_access(0);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_enable_fifo_access
*
* This routine enables/disables access to the vip fifo.
* DIAGNOSTIC USE ONLY
*--------------------------------------------------------------------------*/
int
vip_enable_fifo_access(int enable)
{
unsigned long cw2;
cw2 = READ_VIP32(VIP_CONTROL2);
if (enable)
cw2 |= VIP_CONTROL2_FIFO_ACCESS;
else
cw2 &= ~VIP_CONTROL2_FIFO_ACCESS;
WRITE_VIP32(VIP_CONTROL2, cw2);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_get_power_characteristics
*
* This routine returns the current VIP clock gating state in a
* VIPPOWERBUFFER.
*--------------------------------------------------------------------------*/
int
vip_get_power_characteristics(VIPPOWERBUFFER * buffer)
{
Q_WORD q_word;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
/* READ THE EXISTING STATE */
msr_read64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_PM, &q_word);
/* DECODE THE CLOCK GATING BITS */
buffer->glink_clock_mode = (int) (q_word.low & VIP_MSR_POWER_GLINK);
buffer->vip_clock_mode = (int) (q_word.low & VIP_MSR_POWER_CLOCK);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_get_priority_characteristics
*
* This routine returns the priority characteristics in the supplied
* VIPPRIORITYBUFFER.
*--------------------------------------------------------------------------*/
int
vip_get_priority_characteristics(VIPPRIORITYBUFFER * buffer)
{
Q_WORD q_word;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
/* READ THE CURRENT STATE */
msr_read64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_CONFIG, &q_word);
/* DECODE THE PRIORITIES */
buffer->secondary = (q_word.low & VIP_MSR_MCR_SECOND_PRIORITY_MASK) >>
VIP_MSR_MCR_SECOND_PRIORITY_SHIFT;
buffer->primary = (q_word.low & VIP_MSR_MCR_PRIMARY_PRIORITY_MASK) >>
VIP_MSR_MCR_PRIMARY_PRIORITY_SHIFT;
buffer->pid = q_word.low & VIP_MSR_MCR_PID_MASK;
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vip_get_capability_characteristics
*
* This routine returns revision information for the device.
*--------------------------------------------------------------------------*/
int
vip_get_capability_characteristics(VIPCAPABILITIESBUFFER * buffer)
{
Q_WORD q_word;
if (!buffer)
return CIM_STATUS_INVALIDPARAMS;
/* READ THE CURRENT MSR CONTENTS */
msr_read64(MSR_DEVICE_GEODELX_VIP, MSR_GEODELINK_CAP, &q_word);
/* DECODE THE REVISIONS */
buffer->revision_id = (q_word.low & VIP_MSR_CAP_REVID_MASK) >>
VIP_MSR_CAP_REVID_SHIFT;
buffer->device_id = (q_word.low & VIP_MSR_CAP_DEVID_MASK) >>
VIP_MSR_CAP_DEVID_SHIFT;
buffer->n_clock_domains = (q_word.low & VIP_MSR_CAP_NCLK_MASK) >>
VIP_MSR_CAP_NCLK_SHIFT;
buffer->n_smi_registers = (q_word.low & VIP_MSR_CAP_NSMI_MASK) >>
VIP_MSR_CAP_NSMI_SHIFT;
return CIM_STATUS_OK;
}
#endif
|