Skip to contentSkip to conversation

video: add sh_mobile_lcdcfb memory resource

PATCH In review Magnus Damm 2 participants 3 messages May 12, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 video: add sh_mobile_lcdcfb memory resource

From: Magnus Damm <[email protected]>

This patch adds memory resource support to the LCDC driver. With this applied the physical memory range used for framebuffer data will show up in /proc/iomem together with other SuperH Mobile devices.

---

 drivers/video/sh_mobile_lcdcfb.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/video/sh_mobile_lcdcfb.c +16 -0
@@ -35,6 +35,7 @@ struct sh_mobile_lcdc_chan {
 	struct fb_deferred_io defio;
 	unsigned long frame_end;
 	wait_queue_head_t frame_end_wait;
+	struct resource memory;
 };
 
 struct sh_mobile_lcdc_priv {
@@ -813,12 +814,26 @@ static int __init sh_mobile_lcdc_probe(s
 			break;
 		}
 
+		res = &priv->ch[i].memory;
+		res->name = "lcdc";
+		res->start = priv->ch[i].dma_handle;
+		res->end = res->start + info->fix.smem_len - 1;
+		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+		error = insert_resource(&iomem_resource, res);
+		if (error) {
+			dev_err(&pdev->dev, "unable to request resource\n");
+			dma_free_coherent(&pdev->dev, info->fix.smem_len,
+					  buf, priv->ch[i].dma_handle);
+			break;
+		}
+
 		info->pseudo_palette = &priv->ch[i].pseudo_palette;
 		info->flags = FBINFO_FLAG_DEFAULT;
 
 		error = fb_alloc_cmap(&info->cmap, PALETTE_NR, 0);
 		if (error < 0) {
 			dev_err(&pdev->dev, "unable to allocate cmap\n");
+			release_resource(res);
 			dma_free_coherent(&pdev->dev, info->fix.smem_len,
 					  buf, priv->ch[i].dma_handle);
 			break;
@@ -887,6 +902,7 @@ static int sh_mobile_lcdc_remove(struct 
 		if (!info->device)
 			continue;
 
+		release_resource(&priv->ch[i].memory);
 		dma_free_coherent(&pdev->dev, info->fix.smem_len,
 				  info->screen_base, priv->ch[i].dma_handle);
 		fb_dealloc_cmap(&info->cmap);
#1 lore raw
Quoted 8 lines · Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds memory resource support to the LCDC driver. With this applied the physical memory range used for framebuffer data will show up in /proc/iomem together with other SuperH Mobile devices.

Drivers have no place doing this on their own, besides, insert_resource() is not available to modules. The platform device code already takes care of this, so perhaps I am missing what the point of this change is?

#2 lore raw
Quoted 8 lines · Paul Mundt
Quoted 7 lines · Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds memory resource support to the LCDC driver. With this applied the physical memory range used for framebuffer data will show up in /proc/iomem together with other SuperH Mobile devices.

Quoted 5 lines
Quoted 1 line

Drivers have no place doing this on their own, besides, insert_resource() is not available to modules. The platform device code already takes care of this, so perhaps I am missing what the point of this change is?

Other SuperH Mobile multimedia blocks like the CEU and VEU/VPU/JPU all get passed a physically contiguous area of memory as platform data. So for those blocks the memory range show up in /proc/iomem. For the LCDC this does not happen today.

Thanks for pointing out the module issue. I guess the proper fix would be to pass a struct resource with memory to the LCDC driver as well instead of this patch.

Cheeers,

/ magnus