@@ -41,7 +41,7 @@ struct vidi_context {
41
41
struct exynos_drm_crtc * crtc ;
42
42
struct drm_connector connector ;
43
43
struct exynos_drm_plane planes [WINDOWS_NR ];
44
- struct edid * raw_edid ;
44
+ const struct drm_edid * raw_edid ;
45
45
unsigned int clkdiv ;
46
46
unsigned int connected ;
47
47
bool suspended ;
@@ -195,12 +195,11 @@ static ssize_t vidi_store_connection(struct device *dev,
195
195
if (ctx -> connected > 1 )
196
196
return - EINVAL ;
197
197
198
- /* use fake edid data for test. */
199
- if (!ctx -> raw_edid )
200
- ctx -> raw_edid = (struct edid * )fake_edid_info ;
201
-
202
- /* if raw_edid isn't same as fake data then it can't be tested. */
203
- if (ctx -> raw_edid != (struct edid * )fake_edid_info ) {
198
+ /*
199
+ * Use fake edid data for test. If raw_edid is set then it can't be
200
+ * tested.
201
+ */
202
+ if (ctx -> raw_edid ) {
204
203
DRM_DEV_DEBUG_KMS (dev , "edid data is not fake data.\n" );
205
204
return - EINVAL ;
206
205
}
@@ -246,30 +245,28 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
246
245
}
247
246
248
247
if (vidi -> connection ) {
249
- struct edid * raw_edid ;
248
+ const struct drm_edid * drm_edid ;
249
+ const struct edid * raw_edid ;
250
+ size_t size ;
250
251
251
- raw_edid = (struct edid * )(unsigned long )vidi -> edid ;
252
- if (!drm_edid_is_valid (raw_edid )) {
252
+ raw_edid = (const struct edid * )(unsigned long )vidi -> edid ;
253
+ size = (raw_edid -> extensions + 1 ) * EDID_LENGTH ;
254
+
255
+ drm_edid = drm_edid_alloc (raw_edid , size );
256
+ if (!drm_edid )
257
+ return - ENOMEM ;
258
+
259
+ if (!drm_edid_valid (drm_edid )) {
260
+ drm_edid_free (drm_edid );
253
261
DRM_DEV_DEBUG_KMS (ctx -> dev ,
254
262
"edid data is invalid.\n" );
255
263
return - EINVAL ;
256
264
}
257
- ctx -> raw_edid = drm_edid_duplicate (raw_edid );
258
- if (!ctx -> raw_edid ) {
259
- DRM_DEV_DEBUG_KMS (ctx -> dev ,
260
- "failed to allocate raw_edid.\n" );
261
- return - ENOMEM ;
262
- }
265
+ ctx -> raw_edid = drm_edid ;
263
266
} else {
264
- /*
265
- * with connection = 0, free raw_edid
266
- * only if raw edid data isn't same as fake data.
267
- */
268
- if (ctx -> raw_edid && ctx -> raw_edid !=
269
- (struct edid * )fake_edid_info ) {
270
- kfree (ctx -> raw_edid );
271
- ctx -> raw_edid = NULL ;
272
- }
267
+ /* with connection = 0, free raw_edid */
268
+ drm_edid_free (ctx -> raw_edid );
269
+ ctx -> raw_edid = NULL ;
273
270
}
274
271
275
272
ctx -> connected = vidi -> connection ;
@@ -307,31 +304,22 @@ static const struct drm_connector_funcs vidi_connector_funcs = {
307
304
static int vidi_get_modes (struct drm_connector * connector )
308
305
{
309
306
struct vidi_context * ctx = ctx_from_connector (connector );
310
- struct edid * edid ;
311
- int edid_len ;
307
+ const struct drm_edid * drm_edid ;
312
308
int count ;
313
309
314
- /*
315
- * the edid data comes from user side and it would be set
316
- * to ctx->raw_edid through specific ioctl.
317
- */
318
- if (!ctx -> raw_edid ) {
319
- DRM_DEV_DEBUG_KMS (ctx -> dev , "raw_edid is null.\n" );
320
- return 0 ;
321
- }
310
+ if (ctx -> raw_edid )
311
+ drm_edid = drm_edid_dup (ctx -> raw_edid );
312
+ else
313
+ drm_edid = drm_edid_alloc (fake_edid_info , sizeof (fake_edid_info ));
322
314
323
- edid_len = (1 + ctx -> raw_edid -> extensions ) * EDID_LENGTH ;
324
- edid = kmemdup (ctx -> raw_edid , edid_len , GFP_KERNEL );
325
- if (!edid ) {
326
- DRM_DEV_DEBUG_KMS (ctx -> dev , "failed to allocate edid\n" );
315
+ if (!drm_edid )
327
316
return 0 ;
328
- }
329
317
330
- drm_connector_update_edid_property (connector , edid );
318
+ drm_edid_connector_update (connector , drm_edid );
331
319
332
- count = drm_add_edid_modes (connector , edid );
320
+ count = drm_edid_connector_add_modes (connector );
333
321
334
- kfree ( edid );
322
+ drm_edid_free ( drm_edid );
335
323
336
324
return count ;
337
325
}
@@ -471,10 +459,8 @@ static void vidi_remove(struct platform_device *pdev)
471
459
{
472
460
struct vidi_context * ctx = platform_get_drvdata (pdev );
473
461
474
- if (ctx -> raw_edid != (struct edid * )fake_edid_info ) {
475
- kfree (ctx -> raw_edid );
476
- ctx -> raw_edid = NULL ;
477
- }
462
+ drm_edid_free (ctx -> raw_edid );
463
+ ctx -> raw_edid = NULL ;
478
464
479
465
component_del (& pdev -> dev , & vidi_component_ops );
480
466
}
0 commit comments