@@ -166,11 +166,24 @@ module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600)
166
166
MODULE_PARM_DESC (vblankoffdelay , "Delay until vblank irq auto-disable [msecs] (0: never disable, <0: disable immediately)" );
167
167
MODULE_PARM_DESC (timestamp_precision_usec , "Max. error on timestamps [usecs]" );
168
168
169
+ static struct drm_vblank_crtc *
170
+ drm_vblank_crtc (struct drm_device * dev , unsigned int pipe )
171
+ {
172
+ return & dev -> vblank [pipe ];
173
+ }
174
+
175
+ struct drm_vblank_crtc *
176
+ drm_crtc_vblank_crtc (struct drm_crtc * crtc )
177
+ {
178
+ return drm_vblank_crtc (crtc -> dev , drm_crtc_index (crtc ));
179
+ }
180
+ EXPORT_SYMBOL (drm_crtc_vblank_crtc );
181
+
169
182
static void store_vblank (struct drm_device * dev , unsigned int pipe ,
170
183
u32 vblank_count_inc ,
171
184
ktime_t t_vblank , u32 last )
172
185
{
173
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
186
+ struct drm_vblank_crtc * vblank = drm_vblank_crtc ( dev , pipe ) ;
174
187
175
188
assert_spin_locked (& dev -> vblank_time_lock );
176
189
@@ -184,7 +197,7 @@ static void store_vblank(struct drm_device *dev, unsigned int pipe,
184
197
185
198
static u32 drm_max_vblank_count (struct drm_device * dev , unsigned int pipe )
186
199
{
187
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
200
+ struct drm_vblank_crtc * vblank = drm_vblank_crtc ( dev , pipe ) ;
188
201
189
202
return vblank -> max_vblank_count ?: dev -> max_vblank_count ;
190
203
}
@@ -273,7 +286,7 @@ static void drm_reset_vblank_timestamp(struct drm_device *dev, unsigned int pipe
273
286
static void drm_update_vblank_count (struct drm_device * dev , unsigned int pipe ,
274
287
bool in_vblank_irq )
275
288
{
276
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
289
+ struct drm_vblank_crtc * vblank = drm_vblank_crtc ( dev , pipe ) ;
277
290
u32 cur_vblank , diff ;
278
291
bool rc ;
279
292
ktime_t t_vblank ;
@@ -364,7 +377,7 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
364
377
365
378
u64 drm_vblank_count (struct drm_device * dev , unsigned int pipe )
366
379
{
367
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
380
+ struct drm_vblank_crtc * vblank = drm_vblank_crtc ( dev , pipe ) ;
368
381
u64 count ;
369
382
370
383
if (drm_WARN_ON (dev , pipe >= dev -> num_crtcs ))
@@ -438,7 +451,7 @@ static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
438
451
*/
439
452
void drm_vblank_disable_and_save (struct drm_device * dev , unsigned int pipe )
440
453
{
441
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
454
+ struct drm_vblank_crtc * vblank = drm_vblank_crtc ( dev , pipe ) ;
442
455
unsigned long irqflags ;
443
456
444
457
assert_spin_locked (& dev -> vbl_lock );
@@ -600,7 +613,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
600
613
{
601
614
struct drm_device * dev = crtc -> dev ;
602
615
unsigned int pipe = drm_crtc_index (crtc );
603
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
616
+ struct drm_vblank_crtc * vblank = drm_crtc_vblank_crtc ( crtc ) ;
604
617
int linedur_ns = 0 , framedur_ns = 0 ;
605
618
int dotclock = mode -> crtc_clock ;
606
619
@@ -930,7 +943,7 @@ EXPORT_SYMBOL(drm_crtc_vblank_count);
930
943
static u64 drm_vblank_count_and_time (struct drm_device * dev , unsigned int pipe ,
931
944
ktime_t * vblanktime )
932
945
{
933
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
946
+ struct drm_vblank_crtc * vblank = drm_vblank_crtc ( dev , pipe ) ;
934
947
u64 vblank_count ;
935
948
unsigned int seq ;
936
949
@@ -985,15 +998,14 @@ EXPORT_SYMBOL(drm_crtc_vblank_count_and_time);
985
998
*/
986
999
int drm_crtc_next_vblank_start (struct drm_crtc * crtc , ktime_t * vblanktime )
987
1000
{
988
- unsigned int pipe = drm_crtc_index (crtc );
989
1001
struct drm_vblank_crtc * vblank ;
990
1002
struct drm_display_mode * mode ;
991
1003
u64 vblank_start ;
992
1004
993
1005
if (!drm_dev_has_vblank (crtc -> dev ))
994
1006
return - EINVAL ;
995
1007
996
- vblank = & crtc -> dev -> vblank [ pipe ] ;
1008
+ vblank = drm_crtc_vblank_crtc ( crtc ) ;
997
1009
mode = & vblank -> hwmode ;
998
1010
999
1011
if (!vblank -> framedur_ns || !vblank -> linedur_ns )
@@ -1147,7 +1159,7 @@ static int __enable_vblank(struct drm_device *dev, unsigned int pipe)
1147
1159
1148
1160
static int drm_vblank_enable (struct drm_device * dev , unsigned int pipe )
1149
1161
{
1150
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
1162
+ struct drm_vblank_crtc * vblank = drm_vblank_crtc ( dev , pipe ) ;
1151
1163
int ret = 0 ;
1152
1164
1153
1165
assert_spin_locked (& dev -> vbl_lock );
@@ -1185,7 +1197,7 @@ static int drm_vblank_enable(struct drm_device *dev, unsigned int pipe)
1185
1197
1186
1198
int drm_vblank_get (struct drm_device * dev , unsigned int pipe )
1187
1199
{
1188
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
1200
+ struct drm_vblank_crtc * vblank = drm_vblank_crtc ( dev , pipe ) ;
1189
1201
unsigned long irqflags ;
1190
1202
int ret = 0 ;
1191
1203
@@ -1228,7 +1240,7 @@ EXPORT_SYMBOL(drm_crtc_vblank_get);
1228
1240
1229
1241
void drm_vblank_put (struct drm_device * dev , unsigned int pipe )
1230
1242
{
1231
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
1243
+ struct drm_vblank_crtc * vblank = drm_vblank_crtc ( dev , pipe ) ;
1232
1244
1233
1245
if (drm_WARN_ON (dev , pipe >= dev -> num_crtcs ))
1234
1246
return ;
@@ -1274,7 +1286,7 @@ EXPORT_SYMBOL(drm_crtc_vblank_put);
1274
1286
*/
1275
1287
void drm_wait_one_vblank (struct drm_device * dev , unsigned int pipe )
1276
1288
{
1277
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
1289
+ struct drm_vblank_crtc * vblank = drm_vblank_crtc ( dev , pipe ) ;
1278
1290
int ret ;
1279
1291
u64 last ;
1280
1292
@@ -1327,7 +1339,7 @@ void drm_crtc_vblank_off(struct drm_crtc *crtc)
1327
1339
{
1328
1340
struct drm_device * dev = crtc -> dev ;
1329
1341
unsigned int pipe = drm_crtc_index (crtc );
1330
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
1342
+ struct drm_vblank_crtc * vblank = drm_crtc_vblank_crtc ( crtc ) ;
1331
1343
struct drm_pending_vblank_event * e , * t ;
1332
1344
ktime_t now ;
1333
1345
u64 seq ;
@@ -1405,8 +1417,7 @@ EXPORT_SYMBOL(drm_crtc_vblank_off);
1405
1417
void drm_crtc_vblank_reset (struct drm_crtc * crtc )
1406
1418
{
1407
1419
struct drm_device * dev = crtc -> dev ;
1408
- unsigned int pipe = drm_crtc_index (crtc );
1409
- struct drm_vblank_crtc * vblank = & dev -> vblank [pipe ];
1420
+ struct drm_vblank_crtc * vblank = drm_crtc_vblank_crtc (crtc );
1410
1421
1411
1422
spin_lock_irq (& dev -> vbl_lock );
1412
1423
/*
@@ -1445,8 +1456,7 @@ void drm_crtc_set_max_vblank_count(struct drm_crtc *crtc,
1445
1456
u32 max_vblank_count )
1446
1457
{
1447
1458
struct drm_device * dev = crtc -> dev ;
1448
- unsigned int pipe = drm_crtc_index (crtc );
1449
- struct drm_vblank_crtc * vblank = & dev -> vblank [pipe ];
1459
+ struct drm_vblank_crtc * vblank = drm_crtc_vblank_crtc (crtc );
1450
1460
1451
1461
drm_WARN_ON (dev , dev -> max_vblank_count );
1452
1462
drm_WARN_ON (dev , !READ_ONCE (vblank -> inmodeset ));
@@ -1469,7 +1479,7 @@ void drm_crtc_vblank_on(struct drm_crtc *crtc)
1469
1479
{
1470
1480
struct drm_device * dev = crtc -> dev ;
1471
1481
unsigned int pipe = drm_crtc_index (crtc );
1472
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
1482
+ struct drm_vblank_crtc * vblank = drm_crtc_vblank_crtc ( crtc ) ;
1473
1483
1474
1484
if (drm_WARN_ON (dev , pipe >= dev -> num_crtcs ))
1475
1485
return ;
@@ -1512,7 +1522,7 @@ static void drm_vblank_restore(struct drm_device *dev, unsigned int pipe)
1512
1522
assert_spin_locked (& dev -> vbl_lock );
1513
1523
assert_spin_locked (& dev -> vblank_time_lock );
1514
1524
1515
- vblank = & dev -> vblank [ pipe ] ;
1525
+ vblank = drm_vblank_crtc ( dev , pipe ) ;
1516
1526
drm_WARN_ONCE (dev ,
1517
1527
drm_debug_enabled (DRM_UT_VBL ) && !vblank -> framedur_ns ,
1518
1528
"Cannot compute missed vblanks without frame duration\n" );
@@ -1564,7 +1574,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
1564
1574
union drm_wait_vblank * vblwait ,
1565
1575
struct drm_file * file_priv )
1566
1576
{
1567
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
1577
+ struct drm_vblank_crtc * vblank = drm_vblank_crtc ( dev , pipe ) ;
1568
1578
struct drm_pending_vblank_event * e ;
1569
1579
ktime_t now ;
1570
1580
u64 seq ;
@@ -1872,7 +1882,7 @@ static void drm_handle_vblank_events(struct drm_device *dev, unsigned int pipe)
1872
1882
*/
1873
1883
bool drm_handle_vblank (struct drm_device * dev , unsigned int pipe )
1874
1884
{
1875
- struct drm_vblank_crtc * vblank = & dev -> vblank [ pipe ] ;
1885
+ struct drm_vblank_crtc * vblank = drm_vblank_crtc ( dev , pipe ) ;
1876
1886
unsigned long irqflags ;
1877
1887
bool disable_irq ;
1878
1888
@@ -1981,7 +1991,7 @@ int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
1981
1991
1982
1992
pipe = drm_crtc_index (crtc );
1983
1993
1984
- vblank = & dev -> vblank [ pipe ] ;
1994
+ vblank = drm_crtc_vblank_crtc ( crtc ) ;
1985
1995
vblank_enabled = dev -> vblank_disable_immediate && READ_ONCE (vblank -> enabled );
1986
1996
1987
1997
if (!vblank_enabled ) {
@@ -2046,7 +2056,7 @@ int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data,
2046
2056
2047
2057
pipe = drm_crtc_index (crtc );
2048
2058
2049
- vblank = & dev -> vblank [ pipe ] ;
2059
+ vblank = drm_crtc_vblank_crtc ( crtc ) ;
2050
2060
2051
2061
e = kzalloc (sizeof (* e ), GFP_KERNEL );
2052
2062
if (e == NULL )
0 commit comments