block: fix warning with calling smp_processor_id() in preemptible section
[pandora-kernel.git] / drivers / staging / msm / mdp_cursor.c
1 /* Copyright (c) 2008-2009, Code Aurora Forum. All rights reserved.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 and
5  * only version 2 as published by the Free Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17
18 #include <linux/module.h>
19 #include <linux/kernel.h>
20 #include <linux/sched.h>
21 #include <linux/time.h>
22 #include <linux/init.h>
23 #include <linux/interrupt.h>
24 #include <linux/hrtimer.h>
25
26 #include <mach/hardware.h>
27 #include <asm/io.h>
28
29 #include <asm/system.h>
30 #include <asm/mach-types.h>
31 #include <linux/semaphore.h>
32 #include <linux/spinlock.h>
33
34 #include <linux/fb.h>
35
36 #include "mdp.h"
37 #include "msm_fb.h"
38
39 static int cursor_enabled;
40
41 int mdp_hw_cursor_update(struct fb_info *info, struct fb_cursor *cursor)
42 {
43         struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par;
44         struct fb_image *img = &cursor->image;
45         int calpha_en, transp_en;
46         int alpha;
47         int ret = 0;
48
49         if ((img->width > MDP_CURSOR_WIDTH) ||
50             (img->height > MDP_CURSOR_HEIGHT) ||
51             (img->depth != 32))
52                 return -EINVAL;
53
54         if (cursor->set & FB_CUR_SETPOS)
55                 MDP_OUTP(MDP_BASE + 0x9004c, (img->dy << 16) | img->dx);
56
57         if (cursor->set & FB_CUR_SETIMAGE) {
58                 ret = copy_from_user(mfd->cursor_buf, img->data,
59                                         img->width*img->height*4);
60                 if (ret)
61                         return ret;
62
63                 if (img->bg_color == 0xffffffff)
64                         transp_en = 0;
65                 else
66                         transp_en = 1;
67
68                 alpha = (img->fg_color & 0xff000000) >> 24;
69
70                 if (alpha)
71                         calpha_en = 0x2; /* xrgb */
72                 else
73                         calpha_en = 0x1; /* argb */
74
75                 MDP_OUTP(MDP_BASE + 0x90044, (img->height << 16) | img->width);
76                 MDP_OUTP(MDP_BASE + 0x90048, mfd->cursor_buf_phys);
77                 /* order the writes the cursor_buf before updating the
78                  * hardware */
79 //              dma_coherent_pre_ops();
80                 MDP_OUTP(MDP_BASE + 0x90060,
81                          (transp_en << 3) | (calpha_en << 1) |
82                          (inp32(MDP_BASE + 0x90060) & 0x1));
83 #ifdef CONFIG_FB_MSM_MDP40
84                 MDP_OUTP(MDP_BASE + 0x90064, (alpha << 24));
85                 MDP_OUTP(MDP_BASE + 0x90068, (0xffffff & img->bg_color));
86                 MDP_OUTP(MDP_BASE + 0x9006C, (0xffffff & img->bg_color));
87 #else
88                 MDP_OUTP(MDP_BASE + 0x90064,
89                          (alpha << 24) | (0xffffff & img->bg_color));
90                 MDP_OUTP(MDP_BASE + 0x90068, 0);
91 #endif
92         }
93
94         if ((cursor->enable) && (!cursor_enabled)) {
95                 cursor_enabled = 1;
96                 MDP_OUTP(MDP_BASE + 0x90060, inp32(MDP_BASE + 0x90060) | 0x1);
97         } else if ((!cursor->enable) && (cursor_enabled)) {
98                 cursor_enabled = 0;
99                 MDP_OUTP(MDP_BASE + 0x90060,
100                          inp32(MDP_BASE + 0x90060) & (~0x1));
101         }
102
103         return 0;
104 }