Skip to content

Commit 759ef92

Browse files
author
Thomas Zimmermann
committed
drm/bochs: Use helpers for struct drm_edid
Implement a read function for struct drm_edid and read the EDID data with drm_edit_read_custom(). Update the connector data accordingly. The EDID data comes from the emulator itself and the connector stores a copy in its EDID property. The drm_edid field in struct bochs_device is therefore not required. Remove it. If qemu provides no EDID data, install default display modes as before. Signed-off-by: Thomas Zimmermann <[email protected]> Acked-by: Gerd Hoffmann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent c5c4c8f commit 759ef92

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

drivers/gpu/drm/tiny/bochs.c

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ struct bochs_device {
8585
u16 yres_virtual;
8686
u32 stride;
8787
u32 bpp;
88-
const struct drm_edid *drm_edid;
8988

9089
/* drm */
9190
struct drm_device *dev;
@@ -172,12 +171,14 @@ static void bochs_hw_set_little_endian(struct bochs_device *bochs)
172171
#define bochs_hw_set_native_endian(_b) bochs_hw_set_little_endian(_b)
173172
#endif
174173

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)
177175
{
178176
struct bochs_device *bochs = data;
179177
size_t i, start = block * EDID_LENGTH;
180178

179+
if (!bochs->mmio)
180+
return -1;
181+
181182
if (start + len > 0x400 /* vga register offset */)
182183
return -1;
183184

@@ -187,25 +188,20 @@ static int bochs_get_edid_block(void *data, u8 *buf,
187188
return 0;
188189
}
189190

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)
191192
{
193+
struct drm_device *dev = connector->dev;
194+
struct bochs_device *bochs = dev->dev_private;
192195
u8 header[8];
193196

194-
if (!bochs->mmio)
195-
return -1;
196-
197197
/* check header to detect whenever edid support is enabled in qemu */
198198
bochs_get_edid_block(bochs, header, 0, ARRAY_SIZE(header));
199199
if (drm_edid_header_is_valid(header) != 8)
200-
return -1;
200+
return NULL;
201201

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");
207203

208-
return 0;
204+
return drm_edid_read_custom(connector, bochs_get_edid_block, bochs);
209205
}
210206

211207
static int bochs_hw_init(struct drm_device *dev)
@@ -303,7 +299,6 @@ static void bochs_hw_fini(struct drm_device *dev)
303299
if (bochs->fb_map)
304300
iounmap(bochs->fb_map);
305301
pci_release_regions(to_pci_dev(dev->dev));
306-
drm_edid_free(bochs->drm_edid);
307302
}
308303

309304
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 = {
469464
.cleanup_fb = drm_gem_vram_simple_display_pipe_cleanup_fb,
470465
};
471466

472-
static int bochs_connector_get_modes(struct drm_connector *connector)
467+
static int bochs_connector_helper_get_modes(struct drm_connector *connector)
473468
{
469+
const struct drm_edid *edid;
474470
int count;
475471

476-
count = drm_edid_connector_add_modes(connector);
472+
edid = bochs_hw_read_edid(connector);
477473

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);
479480
count = drm_add_modes_noedid(connector, 8192, 8192);
480481
drm_set_preferred_mode(connector, defx, defy);
481482
}
483+
482484
return count;
483485
}
484486

485487
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,
487489
};
488490

489491
static const struct drm_connector_funcs bochs_connector_connector_funcs = {
@@ -501,14 +503,8 @@ static void bochs_connector_init(struct drm_device *dev)
501503

502504
drm_connector_init(dev, connector, &bochs_connector_connector_funcs,
503505
DRM_MODE_CONNECTOR_VIRTUAL);
506+
drm_connector_attach_edid_property(connector);
504507
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-
}
512508
}
513509

514510
static const struct drm_mode_config_funcs bochs_mode_funcs = {

0 commit comments

Comments
 (0)