Android-x86
Fork
Spenden

  • R/O
  • HTTP
  • SSH
  • HTTPS

hardware-menlow-psb: Commit

hardware/menlow/psb


Commit MetaInfo

Revisionf983cf76dd092c91eb0820d9fc59a96ed6581470 (tree)
Zeit2010-08-05 20:15:30
AutorOwen Kwon <pinebud@gmai...>
CommiterOwen Kwon

Log Message

copied psb_fb.c from 2.6.32

Ändern Zusammenfassung

Diff

--- a/psb_fb.c
+++ b/psb_fb.c
@@ -32,14 +32,14 @@
3232 #include <linux/init.h>
3333 #include <linux/console.h>
3434
35-#define BUFFER_COUNT 2
36-
3735 #include "drmP.h"
3836 #include "drm.h"
3937 #include "drm_crtc.h"
4038 #include "psb_drv.h"
4139 #include "drm_compat.h"
4240
41+#define BUFFER_COUNT 2
42+
4343 #define SII_1392_WA
4444 #ifdef SII_1392_WA
4545 extern int SII_1392;
@@ -104,8 +104,7 @@ static int psbfb_setcolreg(unsigned regno, unsigned red, unsigned green,
104104 if (regno > 15)
105105 return 1;
106106
107- /*
108- * //this sets gamma of psb and it ruins color
107+ /* why do we set gamma here? this ruins color setting -_-?
109108 if (crtc->funcs->gamma_set)
110109 crtc->funcs->gamma_set(crtc, red, green, blue, regno);
111110 */
@@ -133,13 +132,11 @@ static int psbfb_setcolreg(unsigned regno, unsigned red, unsigned green,
133132 return 0;
134133 }
135134
135+/* copied from general drm_fb_helper */
136136 static int psbfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
137137 {
138138 struct psbfb_par *par = info->par;
139- struct drm_device *dev = par->dev;
140139 struct drm_framebuffer *fb = par->crtc->fb;
141- struct drm_display_mode *drm_mode;
142- struct drm_output *output;
143140 int depth;
144141 int pitch;
145142 int bpp = var->bits_per_pixel;
@@ -150,155 +147,92 @@ static int psbfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
150147 if (!var->pixclock)
151148 return -EINVAL;
152149
153- /* don't support virtuals for now */
154150 #if (BUFFER_COUNT == 1)
155- if (var->xres_virtual > var->xres)
151+ if (var->yres < var->yres_virtual)
156152 return -EINVAL;
157-
158- if (var->yres_virtual > var->yres)
153+ if (var->xres < var->xres_virtual)
159154 return -EINVAL;
160155 #endif
161156
162157 switch (bpp) {
163- case 8:
164- depth = 8;
165- break;
166- case 16:
167- depth = (var->green.length == 6) ? 16 : 15;
168- break;
169- case 24: /* assume this is 32bpp / depth 24 */
170- bpp = 32;
171- /* fallthrough */
172- case 32:
173- depth = (var->transp.length > 0) ? 32 : 24;
174- break;
175- default:
176- return -EINVAL;
158+ case 8:
159+ depth = 8;
160+ break;
161+ case 16:
162+ depth = (var->green.length == 6) ? 16 : 15;
163+ break;
164+ case 24: /* assume this is 32bpp / depth 24 */
165+ bpp = 32;
166+ /* fallthrough */
167+ case 32:
168+ depth = (var->transp.length > 0) ? 32 : 24;
169+ break;
170+ default:
171+ return -EINVAL;
177172 }
178173
179174 pitch = ((var->xres * ((bpp + 1) / 8)) + 0x3f) & ~0x3f;
180175
181- /* Check that we can resize */
182176 if ((pitch * var->yres) > (fb->bo->num_pages << PAGE_SHIFT)) {
183-#if 1
184- /* Need to resize the fb object.
185- * But the generic fbdev code doesn't really understand
186- * that we can do this. So disable for now.
187- */
188177 DRM_INFO("Can't support requested size, too big!\n");
189178 return -EINVAL;
190-#else
191- int ret;
192- struct drm_buffer_object *fbo = NULL;
193- struct drm_bo_kmap_obj tmp_kmap;
194-
195- /* a temporary BO to check if we could resize in setpar.
196- * Therefore no need to set NO_EVICT.
197- */
198- ret = drm_buffer_object_create(dev,
199- pitch * var->yres,
200- drm_bo_type_kernel,
201- DRM_BO_FLAG_READ |
202- DRM_BO_FLAG_WRITE |
203- DRM_BO_FLAG_MEM_TT |
204- DRM_BO_FLAG_MEM_VRAM,
205- DRM_BO_HINT_DONT_FENCE,
206- 0, 0, &fbo);
207- if (ret || !fbo)
208- return -ENOMEM;
209-
210- ret = drm_bo_kmap(fbo, 0, fbo->num_pages, &tmp_kmap);
211- if (ret) {
212- drm_bo_usage_deref_unlocked(&fbo);
213- return -EINVAL;
214- }
215-
216- drm_bo_kunmap(&tmp_kmap);
217- /* destroy our current fbo! */
218- drm_bo_usage_deref_unlocked(&fbo);
219-#endif
220179 }
221180
222181 switch (depth) {
223- case 8:
224- var->red.offset = 0;
225- var->green.offset = 0;
226- var->blue.offset = 0;
227- var->red.length = 8;
228- var->green.length = 8;
229- var->blue.length = 8;
230- var->transp.length = 0;
231- var->transp.offset = 0;
232- break;
233- case 15:
234- var->red.offset = 10;
235- var->green.offset = 5;
236- var->blue.offset = 0;
237- var->red.length = 5;
238- var->green.length = 5;
239- var->blue.length = 5;
240- var->transp.length = 1;
241- var->transp.offset = 15;
242- break;
243- case 16:
244- var->red.offset = 11;
245- var->green.offset = 5;
246- var->blue.offset = 0;
247- var->red.length = 5;
248- var->green.length = 6;
249- var->blue.length = 5;
250- var->transp.length = 0;
251- var->transp.offset = 0;
252- break;
253- case 24:
254- var->red.offset = 16;
255- var->green.offset = 8;
256- var->blue.offset = 0;
257- var->red.length = 8;
258- var->green.length = 8;
259- var->blue.length = 8;
260- var->transp.length = 0;
261- var->transp.offset = 0;
262- break;
263- case 32:
264- var->red.offset = 16;
265- var->green.offset = 8;
266- var->blue.offset = 0;
267- var->red.length = 8;
268- var->green.length = 8;
269- var->blue.length = 8;
270- var->transp.length = 8;
271- var->transp.offset = 24;
272- break;
273- default:
274- return -EINVAL;
275- }
276-
277-#if 0
278- /* Here we walk the output mode list and look for modes. If we haven't
279- * got it, then bail. Not very nice, so this is disabled.
280- * In the set_par code, we create our mode based on the incoming
281- * parameters. Nicer, but may not be desired by some.
282- */
283- list_for_each_entry(output, &dev->mode_config.output_list, head) {
284- if (output->crtc == par->crtc)
182+ case 8:
183+ var->red.offset = 0;
184+ var->green.offset = 0;
185+ var->blue.offset = 0;
186+ var->red.length = 8;
187+ var->green.length = 8;
188+ var->blue.length = 8;
189+ var->transp.length = 0;
190+ var->transp.offset = 0;
285191 break;
286- }
287-
288- list_for_each_entry(drm_mode, &output->modes, head) {
289- if (drm_mode->hdisplay == var->xres &&
290- drm_mode->vdisplay == var->yres && drm_mode->clock != 0)
192+ case 15:
193+ var->red.offset = 10;
194+ var->green.offset = 5;
195+ var->blue.offset = 0;
196+ var->red.length = 5;
197+ var->green.length = 5;
198+ var->blue.length = 5;
199+ var->transp.length = 1;
200+ var->transp.offset = 15;
291201 break;
202+ case 16:
203+ var->red.offset = 11;
204+ var->green.offset = 5;
205+ var->blue.offset = 0;
206+ var->red.length = 5;
207+ var->green.length = 6;
208+ var->blue.length = 5;
209+ var->transp.length = 0;
210+ var->transp.offset = 0;
211+ break;
212+ case 24:
213+ var->red.offset = 16;
214+ var->green.offset = 8;
215+ var->blue.offset = 0;
216+ var->red.length = 8;
217+ var->green.length = 8;
218+ var->blue.length = 8;
219+ var->transp.length = 0;
220+ var->transp.offset = 0;
221+ break;
222+ case 32:
223+ var->red.offset = 16;
224+ var->green.offset = 8;
225+ var->blue.offset = 0;
226+ var->red.length = 8;
227+ var->green.length = 8;
228+ var->blue.length = 8;
229+ var->transp.length = 8;
230+ var->transp.offset = 24;
231+ break;
232+ default:
233+ return -EINVAL;
292234 }
293235
294- if (!drm_mode)
295- return -EINVAL;
296-#else
297- (void)dev; /* silence warnings */
298- (void)output;
299- (void)drm_mode;
300-#endif
301-
302236 return 0;
303237 }
304238
@@ -331,9 +265,14 @@ static int psbfb_move_fb_bo(struct fb_info *info, struct drm_buffer_object *bo,
331265 return ret;
332266 }
333267
334-static int psbfb_set_par_ex(struct fb_info * info)
268+extern void
269+intel_pipe_set_base(struct drm_crtc *crtc, int x, int y);
270+
271+static int psbfb_set_par_ext(struct fb_info *info)
335272 {
336273 /* need to populate */
274+
275+ return 0;
337276 }
338277
339278 /* this will let fbcon do the mode init */
@@ -373,55 +312,12 @@ static int psbfb_set_par(struct fb_info *info)
373312 pitch = ((var->xres * ((bpp + 1) / 8)) + 0x3f) & ~0x3f;
374313
375314 if ((pitch * var->yres) > (fb->bo->num_pages << PAGE_SHIFT)) {
376-#if 1
377315 /* Need to resize the fb object.
378316 * But the generic fbdev code doesn't really understand
379317 * that we can do this. So disable for now.
380318 */
381319 DRM_INFO("Can't support requested size, too big!\n");
382320 return -EINVAL;
383-#else
384- int ret;
385- struct drm_buffer_object *fbo = NULL, *tfbo;
386- struct drm_bo_kmap_obj tmp_kmap, tkmap;
387-
388- ret = drm_buffer_object_create(dev,
389- pitch * var->yres,
390- drm_bo_type_kernel,
391- DRM_BO_FLAG_READ |
392- DRM_BO_FLAG_WRITE |
393- DRM_BO_FLAG_MEM_TT |
394- DRM_BO_FLAG_MEM_VRAM |
395- DRM_BO_FLAG_NO_EVICT,
396- DRM_BO_HINT_DONT_FENCE,
397- 0, 0, &fbo);
398- if (ret || !fbo) {
399- DRM_ERROR
400- ("failed to allocate new resized framebuffer\n");
401- return -ENOMEM;
402- }
403-
404- ret = drm_bo_kmap(fbo, 0, fbo->num_pages, &tmp_kmap);
405- if (ret) {
406- DRM_ERROR("failed to kmap framebuffer.\n");
407- drm_bo_usage_deref_unlocked(&fbo);
408- return -EINVAL;
409- }
410-
411- DRM_DEBUG("allocated %dx%d fb: 0x%08lx, bo %p\n", fb->width,
412- fb->height, fb->offset, fbo);
413-
414- /* set new screen base */
415- info->screen_base = tmp_kmap.virtual;
416-
417- tkmap = fb->kmap;
418- fb->kmap = tmp_kmap;
419- drm_bo_kunmap(&tkmap);
420-
421- tfbo = fb->bo;
422- fb->bo = fbo;
423- drm_bo_usage_deref_unlocked(&tfbo);
424-#endif
425321 }
426322
427323 fb->offset = fb->bo->offset - dev_priv->pg->gatt_start;
@@ -439,34 +335,11 @@ static int psbfb_set_par(struct fb_info *info)
439335 info->fix.smem_start = dev->mode_config.fb_base + fb->offset;
440336
441337 /* we have to align the output base address because the fb->bo
442- may be moved in the previous drm_bo_do_validate().
338+ may be moved in the previous psb_drm_bo_do_validate().
443339 Otherwise the output screens may go black when exit the X
444340 window and re-enter the console */
445341 info->screen_base = fb->kmap.virtual;
446342
447-#if 0
448- /* relates to resize - disable */
449- info->fix.smem_len = info->fix.line_length * var->yres;
450- info->screen_size = info->fix.smem_len; /* ??? */
451-#endif
452-
453- /* Should we walk the output's modelist or just create our own ???
454- * For now, we create and destroy a mode based on the incoming
455- * parameters. But there's commented out code below which scans
456- * the output list too.
457- */
458-#if 0
459- list_for_each_entry(output, &dev->mode_config.output_list, head) {
460- if (output->crtc == par->crtc)
461- break;
462- }
463-
464- list_for_each_entry(drm_mode, &output->modes, head) {
465- if (drm_mode->hdisplay == var->xres &&
466- drm_mode->vdisplay == var->yres && drm_mode->clock != 0)
467- break;
468- }
469-#else
470343 (void)output; /* silence warning */
471344
472345 drm_mode = drm_mode_create(dev);
@@ -482,7 +355,6 @@ static int psbfb_set_par(struct fb_info *info)
482355 drm_mode->vrefresh = drm_mode_vrefresh(drm_mode);
483356 drm_mode_set_name(drm_mode);
484357 drm_mode_set_crtcinfo(drm_mode, CRTC_INTERLACE_HALVE_V);
485-#endif
486358
487359 if (!drm_crtc_set_mode(par->crtc, drm_mode, 0, 0))
488360 return -EINVAL;
@@ -998,74 +870,22 @@ void psbfb_resume(struct drm_device *dev)
998870 }
999871
1000872 /*
1001- * FIXME: Before kernel inclusion, migrate nopfn to fault.
1002- * Also, these should be the default vm ops for buffer object type fbs.
1003- */
1004-
1005-extern unsigned long drm_bo_vm_nopfn(struct vm_area_struct *vma,
1006- unsigned long address);
1007-
1008-/*
1009873 * This wrapper is a bit ugly and is here because we need access to a mutex
1010874 * that we can lock both around nopfn and around unmap_mapping_range + move.
1011875 * Normally, this would've been done using the bo mutex, but unfortunately
1012- * we cannot lock it around drm_bo_do_validate(), since that would imply
876+ * we cannot lock it around psb_drm_bo_do_validate(), since that would imply
1013877 * recursive locking.
1014878 */
1015879
1016-static unsigned long psbfb_nopfn(struct vm_area_struct *vma,
1017- unsigned long address)
1018-{
1019- struct psbfb_vm_info *vi = (struct psbfb_vm_info *)vma->vm_private_data;
1020- struct vm_area_struct tmp_vma;
1021- unsigned long ret;
1022-
1023- mutex_lock(&vi->vm_mutex);
1024- tmp_vma = *vma;
1025- tmp_vma.vm_private_data = vi->bo;
1026- ret = drm_bo_vm_nopfn(&tmp_vma, address);
1027- mutex_unlock(&vi->vm_mutex);
1028- return ret;
1029-}
1030-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
1031-static int psbfb_fault(struct vm_area_struct *vma,
1032- struct vm_fault *vmf)
1033-{
1034- struct psbfb_vm_info *vi = (struct psbfb_vm_info *)vma->vm_private_data;
1035- struct vm_area_struct tmp_vma;
1036- unsigned long ret;
1037-
1038- unsigned long address = (unsigned long)vmf->virtual_address;
1039-
1040- mutex_lock(&vi->vm_mutex);
1041- tmp_vma = *vma;
1042- tmp_vma.vm_private_data = vi->bo;
1043- ret = drm_bo_vm_nopfn(&tmp_vma, address);
1044- mutex_unlock(&vi->vm_mutex);
1045- return ret;
1046-}
1047-#endif
1048-static void psbfb_vm_open(struct vm_area_struct *vma)
1049-{
1050- struct psbfb_vm_info *vi = (struct psbfb_vm_info *)vma->vm_private_data;
1051-
1052- atomic_inc(&vi->refcount);
1053-}
1054-
1055-static void psbfb_vm_close(struct vm_area_struct *vma)
1056-{
1057- psbfb_vm_info_deref((struct psbfb_vm_info **)&vma->vm_private_data);
1058-}
1059-
1060880 extern int drm_bo_vm_fault(struct vm_area_struct *vma,
1061- struct vm_fault *vmf);
881+ struct vm_fault *vmf);
1062882 extern void drm_bo_vm_open(struct vm_area_struct *vma);
1063883 extern void drm_bo_vm_close(struct vm_area_struct *vma);
1064884
1065885 static struct vm_operations_struct psbfb_vm_ops = {
1066886 .fault = drm_bo_vm_fault,
1067- .open = drm_bo_vm_open,
1068- .close = drm_bo_vm_close,
887+ .open = drm_bo_vm_open, /* unused ?? */
888+ .close = drm_bo_vm_close, /* unused ?? */
1069889 };
1070890
1071891 static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
@@ -1088,10 +908,10 @@ static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
1088908 par->vi->f_mapping = vma->vm_file->f_mapping;
1089909 mutex_unlock(&par->vi->vm_mutex);
1090910
911+ vma->vm_private_data = par->vi->bo;
1091912 vma->vm_ops = &psbfb_vm_ops;
1092913 vma->vm_flags |= VM_PFNMAP;
1093- vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)) ;
1094-
914+ vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
1095915
1096916 return 0;
1097917 }
@@ -1108,13 +928,12 @@ int psbfb_sync(struct fb_info *info)
1108928 return 0;
1109929 }
1110930
1111-extern void intel_pipe_set_base(struct drm_crtc *crtc, int x,int y);
1112-int psbfb_pan_display (struct fb_var_screeninfo *var, struct fb_info *info)
931+int psbfb_pan_display (struct fb_var_screeninfo * var, struct fb_info *info)
1113932 {
1114933 struct psbfb_par *par = info->par;
1115934
1116935 intel_pipe_set_base (par->crtc, var->xoffset, var->yoffset);
1117- msleep(1);
936+ msleep(1); // weird? : we need to change the base actually ??
1118937
1119938 return 0;
1120939 }
@@ -1122,7 +941,7 @@ int psbfb_pan_display (struct fb_var_screeninfo *var, struct fb_info *info)
1122941 static struct fb_ops psbfb_ops = {
1123942 .owner = THIS_MODULE,
1124943 .fb_check_var = psbfb_check_var,
1125- .fb_set_par = psbfb_set_par_ex,
944+ .fb_set_par = psbfb_set_par_ext,
1126945 .fb_setcolreg = psbfb_setcolreg,
1127946 .fb_fillrect = psbfb_fillrect,
1128947 .fb_copyarea = psbfb_copyarea,
@@ -1169,6 +988,10 @@ int psbfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
1169988 fb->width = mode->hdisplay;
1170989 fb->height = mode->vdisplay;
1171990
991+ /*
992+ fb->bits_per_pixel = 32;
993+ fb->depth = 24;
994+ */
1172995 fb->bits_per_pixel = 16;
1173996 fb->depth = 16;
1174997 fb->pitch =
@@ -1177,7 +1000,7 @@ int psbfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
11771000 ALIGN(size, PAGE_SIZE);
11781001
11791002 ret = drm_buffer_object_create(dev,
1180- size,
1003+ size,
11811004 drm_bo_type_kernel,
11821005 DRM_BO_FLAG_READ |
11831006 DRM_BO_FLAG_WRITE |
@@ -1192,7 +1015,7 @@ int psbfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
11921015
11931016 fb->offset = fbo->offset - dev_priv->pg->gatt_start;
11941017 fb->bo = fbo;
1195- DRM_DEBUG("allocated %dx%d fb: 0x%08lx, bo %p\n", fb->width,
1018+ DRM_INFO("allocated %dx%d fb: 0x%08lx, bo %p\n", fb->width,
11961019 fb->height, fb->offset, fbo);
11971020
11981021 fb->fbdev = info;
@@ -1228,8 +1051,9 @@ int psbfb_probe(struct drm_device *dev, struct drm_crtc *crtc)
12281051 info->fix.smem_start = dev->mode_config.fb_base + fb->offset;
12291052 info->fix.smem_len = size;
12301053
1231- info->flags = FBINFO_DEFAULT |
1232- FBINFO_PARTIAL_PAN_OK /*| FBINFO_MISC_ALWAYS_SETPAR */ ;
1054+ info->flags = FBINFO_DEFAULT | FBINFO_PARTIAL_PAN_OK |
1055+ FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT |
1056+ FBINFO_HWACCEL_IMAGEBLIT;
12331057
12341058 ret = drm_bo_kmap(fb->bo, 0, fb->bo->num_pages, &fb->kmap);
12351059 if (ret) {
Show on old repository browser