Lines Matching full:canvas
13 #include <linux/soc/amlogic/meson-canvas.h>
37 spinlock_t lock; /* canvas device lock */
42 static void canvas_write(struct meson_canvas *canvas, u32 reg, u32 val) in canvas_write() argument
44 writel_relaxed(val, canvas->reg_base + reg); in canvas_write()
47 static u32 canvas_read(struct meson_canvas *canvas, u32 reg) in canvas_read() argument
49 return readl_relaxed(canvas->reg_base + reg); in canvas_read()
56 struct meson_canvas *canvas; in meson_canvas_get() local
58 canvas_node = of_parse_phandle(dev->of_node, "amlogic,canvas", 0); in meson_canvas_get()
71 * If priv is NULL, it's probably because the canvas hasn't in meson_canvas_get()
75 canvas = dev_get_drvdata(&canvas_pdev->dev); in meson_canvas_get()
76 if (!canvas) { in meson_canvas_get()
81 return canvas; in meson_canvas_get()
85 int meson_canvas_config(struct meson_canvas *canvas, u8 canvas_index, in meson_canvas_config() argument
93 if (endian && !canvas->supports_endianness) { in meson_canvas_config()
94 dev_err(canvas->dev, in meson_canvas_config()
99 spin_lock_irqsave(&canvas->lock, flags); in meson_canvas_config()
100 if (!canvas->used[canvas_index]) { in meson_canvas_config()
101 dev_err(canvas->dev, in meson_canvas_config()
102 "Trying to setup non allocated canvas %u\n", in meson_canvas_config()
104 spin_unlock_irqrestore(&canvas->lock, flags); in meson_canvas_config()
108 canvas_write(canvas, DMC_CAV_LUT_DATAL, in meson_canvas_config()
112 canvas_write(canvas, DMC_CAV_LUT_DATAH, in meson_canvas_config()
120 canvas_write(canvas, DMC_CAV_LUT_ADDR, in meson_canvas_config()
124 canvas_read(canvas, DMC_CAV_LUT_DATAH); in meson_canvas_config()
125 spin_unlock_irqrestore(&canvas->lock, flags); in meson_canvas_config()
131 int meson_canvas_alloc(struct meson_canvas *canvas, u8 *canvas_index) in meson_canvas_alloc() argument
136 spin_lock_irqsave(&canvas->lock, flags); in meson_canvas_alloc()
138 if (!canvas->used[i]) { in meson_canvas_alloc()
139 canvas->used[i] = 1; in meson_canvas_alloc()
140 spin_unlock_irqrestore(&canvas->lock, flags); in meson_canvas_alloc()
145 spin_unlock_irqrestore(&canvas->lock, flags); in meson_canvas_alloc()
147 dev_err(canvas->dev, "No more canvas available\n"); in meson_canvas_alloc()
152 int meson_canvas_free(struct meson_canvas *canvas, u8 canvas_index) in meson_canvas_free() argument
156 spin_lock_irqsave(&canvas->lock, flags); in meson_canvas_free()
157 if (!canvas->used[canvas_index]) { in meson_canvas_free()
158 dev_err(canvas->dev, in meson_canvas_free()
159 "Trying to free unused canvas %u\n", canvas_index); in meson_canvas_free()
160 spin_unlock_irqrestore(&canvas->lock, flags); in meson_canvas_free()
163 canvas->used[canvas_index] = 0; in meson_canvas_free()
164 spin_unlock_irqrestore(&canvas->lock, flags); in meson_canvas_free()
172 struct meson_canvas *canvas; in meson_canvas_probe() local
175 canvas = devm_kzalloc(dev, sizeof(*canvas), GFP_KERNEL); in meson_canvas_probe()
176 if (!canvas) in meson_canvas_probe()
179 canvas->reg_base = devm_platform_ioremap_resource(pdev, 0); in meson_canvas_probe()
180 if (IS_ERR(canvas->reg_base)) in meson_canvas_probe()
181 return PTR_ERR(canvas->reg_base); in meson_canvas_probe()
183 canvas->supports_endianness = of_device_get_match_data(dev); in meson_canvas_probe()
185 canvas->dev = dev; in meson_canvas_probe()
186 spin_lock_init(&canvas->lock); in meson_canvas_probe()
187 dev_set_drvdata(dev, canvas); in meson_canvas_probe()
193 { .compatible = "amlogic,meson8-canvas", .data = (void *)false, },
194 { .compatible = "amlogic,meson8b-canvas", .data = (void *)false, },
195 { .compatible = "amlogic,meson8m2-canvas", .data = (void *)false, },
196 { .compatible = "amlogic,canvas", .data = (void *)true, },
204 .name = "amlogic-canvas",
210 MODULE_DESCRIPTION("Amlogic Canvas driver");