@@ -85,7 +85,6 @@ struct bochs_device {
85
85
u16 yres_virtual ;
86
86
u32 stride ;
87
87
u32 bpp ;
88
- const struct drm_edid * drm_edid ;
89
88
90
89
/* drm */
91
90
struct drm_device * dev ;
@@ -172,12 +171,14 @@ static void bochs_hw_set_little_endian(struct bochs_device *bochs)
172
171
#define bochs_hw_set_native_endian (_b ) bochs_hw_set_little_endian(_b)
173
172
#endif
174
173
175
- static int bochs_get_edid_block (void * data , u8 * buf ,
176
- unsigned int block , size_t len )
174
+ static int bochs_get_edid_block (void * data , u8 * buf , unsigned int block , size_t len )
177
175
{
178
176
struct bochs_device * bochs = data ;
179
177
size_t i , start = block * EDID_LENGTH ;
180
178
179
+ if (!bochs -> mmio )
180
+ return -1 ;
181
+
181
182
if (start + len > 0x400 /* vga register offset */ )
182
183
return -1 ;
183
184
@@ -187,25 +188,20 @@ static int bochs_get_edid_block(void *data, u8 *buf,
187
188
return 0 ;
188
189
}
189
190
190
- static int bochs_hw_load_edid (struct bochs_device * bochs )
191
+ static const struct drm_edid * bochs_hw_read_edid (struct drm_connector * connector )
191
192
{
193
+ struct drm_device * dev = connector -> dev ;
194
+ struct bochs_device * bochs = dev -> dev_private ;
192
195
u8 header [8 ];
193
196
194
- if (!bochs -> mmio )
195
- return -1 ;
196
-
197
197
/* check header to detect whenever edid support is enabled in qemu */
198
198
bochs_get_edid_block (bochs , header , 0 , ARRAY_SIZE (header ));
199
199
if (drm_edid_header_is_valid (header ) != 8 )
200
- return -1 ;
200
+ return NULL ;
201
201
202
- drm_edid_free (bochs -> drm_edid );
203
- bochs -> drm_edid = drm_edid_read_custom (& bochs -> connector ,
204
- bochs_get_edid_block , bochs );
205
- if (!bochs -> drm_edid )
206
- return -1 ;
202
+ drm_dbg (dev , "Found EDID data blob.\n" );
207
203
208
- return 0 ;
204
+ return drm_edid_read_custom ( connector , bochs_get_edid_block , bochs ) ;
209
205
}
210
206
211
207
static int bochs_hw_init (struct drm_device * dev )
@@ -303,7 +299,6 @@ static void bochs_hw_fini(struct drm_device *dev)
303
299
if (bochs -> fb_map )
304
300
iounmap (bochs -> fb_map );
305
301
pci_release_regions (to_pci_dev (dev -> dev ));
306
- drm_edid_free (bochs -> drm_edid );
307
302
}
308
303
309
304
static void bochs_hw_blank (struct bochs_device * bochs , bool blank )
@@ -469,21 +464,28 @@ static const struct drm_simple_display_pipe_funcs bochs_pipe_funcs = {
469
464
.cleanup_fb = drm_gem_vram_simple_display_pipe_cleanup_fb ,
470
465
};
471
466
472
- static int bochs_connector_get_modes (struct drm_connector * connector )
467
+ static int bochs_connector_helper_get_modes (struct drm_connector * connector )
473
468
{
469
+ const struct drm_edid * edid ;
474
470
int count ;
475
471
476
- count = drm_edid_connector_add_modes (connector );
472
+ edid = bochs_hw_read_edid (connector );
477
473
478
- if (!count ) {
474
+ if (edid ) {
475
+ drm_edid_connector_update (connector , edid );
476
+ count = drm_edid_connector_add_modes (connector );
477
+ drm_edid_free (edid );
478
+ } else {
479
+ drm_edid_connector_update (connector , NULL );
479
480
count = drm_add_modes_noedid (connector , 8192 , 8192 );
480
481
drm_set_preferred_mode (connector , defx , defy );
481
482
}
483
+
482
484
return count ;
483
485
}
484
486
485
487
static const struct drm_connector_helper_funcs bochs_connector_connector_helper_funcs = {
486
- .get_modes = bochs_connector_get_modes ,
488
+ .get_modes = bochs_connector_helper_get_modes ,
487
489
};
488
490
489
491
static const struct drm_connector_funcs bochs_connector_connector_funcs = {
@@ -501,14 +503,8 @@ static void bochs_connector_init(struct drm_device *dev)
501
503
502
504
drm_connector_init (dev , connector , & bochs_connector_connector_funcs ,
503
505
DRM_MODE_CONNECTOR_VIRTUAL );
506
+ drm_connector_attach_edid_property (connector );
504
507
drm_connector_helper_add (connector , & bochs_connector_connector_helper_funcs );
505
-
506
- bochs_hw_load_edid (bochs );
507
- if (bochs -> drm_edid ) {
508
- DRM_INFO ("Found EDID data blob.\n" );
509
- drm_connector_attach_edid_property (connector );
510
- drm_edid_connector_update (& bochs -> connector , bochs -> drm_edid );
511
- }
512
508
}
513
509
514
510
static const struct drm_mode_config_funcs bochs_mode_funcs = {
0 commit comments