2 * Copyright (C) 2008 Maarten Maathuis.
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #include "nv50_crtc.h"
30 #include "nv50_display.h"
32 static int nv50_fb_bind(struct nv50_crtc *crtc, struct nv50_fb_info *info)
39 DRM_ERROR("crtc %p info %p\n",crtc, info);
43 if (!info->block || !info->width || !info->height || !info->depth || !info->bpp || !info->pitch) {
44 DRM_ERROR("block %p width %d height %d depth %d bpp %d pitch %d\n", info->block, info->width,
45 info->height, info->depth, info->bpp, info->pitch);
49 crtc->fb->block = info->block;
50 crtc->fb->width = info->width;
51 crtc->fb->height = info->height;
53 crtc->fb->y = info->x;
54 crtc->fb->x = info->y;
56 crtc->fb->depth = info->depth;
57 crtc->fb->bpp = info->bpp;
59 crtc->fb->pitch = info->pitch;
61 /* update lut if needed */
62 if (crtc->fb->depth != crtc->lut->depth) {
63 int r_size = 0, g_size = 0, b_size = 0;
64 uint16_t *r_val, *g_val, *b_val;
67 switch (crtc->fb->depth) {
86 r_val = kmalloc(r_size * sizeof(uint16_t), GFP_KERNEL);
87 g_val = kmalloc(g_size * sizeof(uint16_t), GFP_KERNEL);
88 b_val = kmalloc(b_size * sizeof(uint16_t), GFP_KERNEL);
90 if (!r_val || !g_val || !b_val)
93 /* Set the color indices. */
94 for (i = 0; i < r_size; i++) {
97 for (i = 0; i < g_size; i++) {
100 for (i = 0; i < b_size; i++) {
104 rval = crtc->lut->set(crtc, r_val, g_val, b_val);
106 /* free before returning */
118 int nv50_fb_create(struct nv50_crtc *crtc)
123 crtc->fb = kzalloc(sizeof(struct nv50_fb), GFP_KERNEL);
128 crtc->fb->bind = nv50_fb_bind;
133 int nv50_fb_destroy(struct nv50_crtc *crtc)