diff options
author | Dave Airlie <airlied@starflyer.(none)> | 2005-09-25 00:28:13 -0400 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2005-09-25 00:28:13 -0400 |
commit | b5e89ed53ed8d24f83ba1941c07382af00ed238e (patch) | |
tree | 747bae7a565f88a2e1d5974776eeb054a932c505 /drivers/char/drm/ffb_drv.c | |
parent | 99a2657a29e2d623c3568cd86b27cac13fb63140 (diff) |
drm: lindent the drm directory.
I've been threatening this for a while, so no point hanging around.
This lindents the DRM code which was always really bad in tabbing department.
I've also fixed some misnamed files in comments and removed some trailing
whitespace.
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/ffb_drv.c')
-rw-r--r-- | drivers/char/drm/ffb_drv.c | 139 |
1 files changed, 68 insertions, 71 deletions
diff --git a/drivers/char/drm/ffb_drv.c b/drivers/char/drm/ffb_drv.c index 1bd0d55ee0f0..5c121d6df9f2 100644 --- a/drivers/char/drm/ffb_drv.c +++ b/drivers/char/drm/ffb_drv.c | |||
@@ -33,13 +33,13 @@ typedef struct _ffb_position_t { | |||
33 | 33 | ||
34 | static ffb_position_t *ffb_position; | 34 | static ffb_position_t *ffb_position; |
35 | 35 | ||
36 | static void get_ffb_type(ffb_dev_priv_t *ffb_priv, int instance) | 36 | static void get_ffb_type(ffb_dev_priv_t * ffb_priv, int instance) |
37 | { | 37 | { |
38 | volatile unsigned char *strap_bits; | 38 | volatile unsigned char *strap_bits; |
39 | unsigned char val; | 39 | unsigned char val; |
40 | 40 | ||
41 | strap_bits = (volatile unsigned char *) | 41 | strap_bits = (volatile unsigned char *) |
42 | (ffb_priv->card_phys_base + 0x00200000UL); | 42 | (ffb_priv->card_phys_base + 0x00200000UL); |
43 | 43 | ||
44 | /* Don't ask, you have to read the value twice for whatever | 44 | /* Don't ask, you have to read the value twice for whatever |
45 | * reason to get correct contents. | 45 | * reason to get correct contents. |
@@ -61,7 +61,8 @@ static void get_ffb_type(ffb_dev_priv_t *ffb_priv, int instance) | |||
61 | break; | 61 | break; |
62 | case (0x1 << 5) | (0x0 << 3): | 62 | case (0x1 << 5) | (0x0 << 3): |
63 | ffb_priv->ffb_type = ffb2_prototype; | 63 | ffb_priv->ffb_type = ffb2_prototype; |
64 | printk("ffb%d: Detected FFB2/vertical pre-FCS prototype\n", instance); | 64 | printk("ffb%d: Detected FFB2/vertical pre-FCS prototype\n", |
65 | instance); | ||
65 | break; | 66 | break; |
66 | case (0x1 << 5) | (0x1 << 3): | 67 | case (0x1 << 5) | (0x1 << 3): |
67 | ffb_priv->ffb_type = ffb2_vertical; | 68 | ffb_priv->ffb_type = ffb2_vertical; |
@@ -81,12 +82,13 @@ static void get_ffb_type(ffb_dev_priv_t *ffb_priv, int instance) | |||
81 | break; | 82 | break; |
82 | default: | 83 | default: |
83 | ffb_priv->ffb_type = ffb2_vertical; | 84 | ffb_priv->ffb_type = ffb2_vertical; |
84 | printk("ffb%d: Unknown boardID[%08x], assuming FFB2\n", instance, val); | 85 | printk("ffb%d: Unknown boardID[%08x], assuming FFB2\n", |
86 | instance, val); | ||
85 | break; | 87 | break; |
86 | }; | 88 | }; |
87 | } | 89 | } |
88 | 90 | ||
89 | static void ffb_apply_upa_parent_ranges(int parent, | 91 | static void ffb_apply_upa_parent_ranges(int parent, |
90 | struct linux_prom64_registers *regs) | 92 | struct linux_prom64_registers *regs) |
91 | { | 93 | { |
92 | struct linux_prom64_ranges ranges[PROMREG_MAX]; | 94 | struct linux_prom64_ranges ranges[PROMREG_MAX]; |
@@ -97,7 +99,8 @@ static void ffb_apply_upa_parent_ranges(int parent, | |||
97 | if (strcmp(name, "upa") != 0) | 99 | if (strcmp(name, "upa") != 0) |
98 | return; | 100 | return; |
99 | 101 | ||
100 | len = prom_getproperty(parent, "ranges", (void *) ranges, sizeof(ranges)); | 102 | len = |
103 | prom_getproperty(parent, "ranges", (void *)ranges, sizeof(ranges)); | ||
101 | if (len <= 0) | 104 | if (len <= 0) |
102 | return; | 105 | return; |
103 | 106 | ||
@@ -117,11 +120,11 @@ static void ffb_apply_upa_parent_ranges(int parent, | |||
117 | return; | 120 | return; |
118 | } | 121 | } |
119 | 122 | ||
120 | static int ffb_init_one(drm_device_t *dev, int prom_node, int parent_node, | 123 | static int ffb_init_one(drm_device_t * dev, int prom_node, int parent_node, |
121 | int instance) | 124 | int instance) |
122 | { | 125 | { |
123 | struct linux_prom64_registers regs[2*PROMREG_MAX]; | 126 | struct linux_prom64_registers regs[2 * PROMREG_MAX]; |
124 | ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *)dev->dev_private; | 127 | ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *) dev->dev_private; |
125 | int i; | 128 | int i; |
126 | 129 | ||
127 | ffb_priv->prom_node = prom_node; | 130 | ffb_priv->prom_node = prom_node; |
@@ -132,27 +135,27 @@ static int ffb_init_one(drm_device_t *dev, int prom_node, int parent_node, | |||
132 | ffb_apply_upa_parent_ranges(parent_node, ®s[0]); | 135 | ffb_apply_upa_parent_ranges(parent_node, ®s[0]); |
133 | ffb_priv->card_phys_base = regs[0].phys_addr; | 136 | ffb_priv->card_phys_base = regs[0].phys_addr; |
134 | ffb_priv->regs = (ffb_fbcPtr) | 137 | ffb_priv->regs = (ffb_fbcPtr) |
135 | (regs[0].phys_addr + 0x00600000UL); | 138 | (regs[0].phys_addr + 0x00600000UL); |
136 | get_ffb_type(ffb_priv, instance); | 139 | get_ffb_type(ffb_priv, instance); |
137 | for (i = 0; i < FFB_MAX_CTXS; i++) | 140 | for (i = 0; i < FFB_MAX_CTXS; i++) |
138 | ffb_priv->hw_state[i] = NULL; | 141 | ffb_priv->hw_state[i] = NULL; |
139 | 142 | ||
140 | return 0; | 143 | return 0; |
141 | } | 144 | } |
142 | 145 | ||
143 | static drm_map_t *ffb_find_map(struct file *filp, unsigned long off) | 146 | static drm_map_t *ffb_find_map(struct file *filp, unsigned long off) |
144 | { | 147 | { |
145 | drm_file_t *priv = filp->private_data; | 148 | drm_file_t *priv = filp->private_data; |
146 | drm_device_t *dev; | 149 | drm_device_t *dev; |
147 | drm_map_list_t *r_list; | 150 | drm_map_list_t *r_list; |
148 | struct list_head *list; | 151 | struct list_head *list; |
149 | drm_map_t *map; | 152 | drm_map_t *map; |
150 | 153 | ||
151 | if (!priv || (dev = priv->dev) == NULL) | 154 | if (!priv || (dev = priv->dev) == NULL) |
152 | return NULL; | 155 | return NULL; |
153 | 156 | ||
154 | list_for_each(list, &dev->maplist->head) { | 157 | list_for_each(list, &dev->maplist->head) { |
155 | r_list = (drm_map_list_t *)list; | 158 | r_list = (drm_map_list_t *) list; |
156 | map = r_list->map; | 159 | map = r_list->map; |
157 | if (!map) | 160 | if (!map) |
158 | continue; | 161 | continue; |
@@ -166,8 +169,7 @@ static drm_map_t *ffb_find_map(struct file *filp, unsigned long off) | |||
166 | unsigned long ffb_get_unmapped_area(struct file *filp, | 169 | unsigned long ffb_get_unmapped_area(struct file *filp, |
167 | unsigned long hint, | 170 | unsigned long hint, |
168 | unsigned long len, | 171 | unsigned long len, |
169 | unsigned long pgoff, | 172 | unsigned long pgoff, unsigned long flags) |
170 | unsigned long flags) | ||
171 | { | 173 | { |
172 | drm_map_t *map = ffb_find_map(filp, pgoff << PAGE_SHIFT); | 174 | drm_map_t *map = ffb_find_map(filp, pgoff << PAGE_SHIFT); |
173 | unsigned long addr = -ENOMEM; | 175 | unsigned long addr = -ENOMEM; |
@@ -175,8 +177,7 @@ unsigned long ffb_get_unmapped_area(struct file *filp, | |||
175 | if (!map) | 177 | if (!map) |
176 | return get_unmapped_area(NULL, hint, len, pgoff, flags); | 178 | return get_unmapped_area(NULL, hint, len, pgoff, flags); |
177 | 179 | ||
178 | if (map->type == _DRM_FRAME_BUFFER || | 180 | if (map->type == _DRM_FRAME_BUFFER || map->type == _DRM_REGISTERS) { |
179 | map->type == _DRM_REGISTERS) { | ||
180 | #ifdef HAVE_ARCH_FB_UNMAPPED_AREA | 181 | #ifdef HAVE_ARCH_FB_UNMAPPED_AREA |
181 | addr = get_fb_unmapped_area(filp, hint, len, pgoff, flags); | 182 | addr = get_fb_unmapped_area(filp, hint, len, pgoff, flags); |
182 | #else | 183 | #else |
@@ -187,7 +188,7 @@ unsigned long ffb_get_unmapped_area(struct file *filp, | |||
187 | 188 | ||
188 | addr = get_unmapped_area(NULL, hint, len + slack, pgoff, flags); | 189 | addr = get_unmapped_area(NULL, hint, len + slack, pgoff, flags); |
189 | if (!(addr & ~PAGE_MASK)) { | 190 | if (!(addr & ~PAGE_MASK)) { |
190 | unsigned long kvirt = (unsigned long) map->handle; | 191 | unsigned long kvirt = (unsigned long)map->handle; |
191 | 192 | ||
192 | if ((kvirt & (SHMLBA - 1)) != (addr & (SHMLBA - 1))) { | 193 | if ((kvirt & (SHMLBA - 1)) != (addr & (SHMLBA - 1))) { |
193 | unsigned long koff, aoff; | 194 | unsigned long koff, aoff; |
@@ -207,9 +208,9 @@ unsigned long ffb_get_unmapped_area(struct file *filp, | |||
207 | return addr; | 208 | return addr; |
208 | } | 209 | } |
209 | 210 | ||
210 | static int ffb_presetup(drm_device_t *dev) | 211 | static int ffb_presetup(drm_device_t * dev) |
211 | { | 212 | { |
212 | ffb_dev_priv_t *ffb_priv; | 213 | ffb_dev_priv_t *ffb_priv; |
213 | int ret = 0; | 214 | int ret = 0; |
214 | int i = 0; | 215 | int i = 0; |
215 | 216 | ||
@@ -224,14 +225,11 @@ static int ffb_presetup(drm_device_t *dev) | |||
224 | memset(ffb_priv, 0, sizeof(*ffb_priv)); | 225 | memset(ffb_priv, 0, sizeof(*ffb_priv)); |
225 | dev->dev_private = ffb_priv; | 226 | dev->dev_private = ffb_priv; |
226 | 227 | ||
227 | ret = ffb_init_one(dev, | 228 | ret = ffb_init_one(dev, ffb_position[i].node, ffb_position[i].root, i); |
228 | ffb_position[i].node, | ||
229 | ffb_position[i].root, | ||
230 | i); | ||
231 | return ret; | 229 | return ret; |
232 | } | 230 | } |
233 | 231 | ||
234 | static void ffb_driver_release(drm_device_t *dev, struct file *filp) | 232 | static void ffb_driver_release(drm_device_t * dev, struct file *filp) |
235 | { | 233 | { |
236 | ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private; | 234 | ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private; |
237 | int context = _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock); | 235 | int context = _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock); |
@@ -239,84 +237,82 @@ static void ffb_driver_release(drm_device_t *dev, struct file *filp) | |||
239 | 237 | ||
240 | idx = context - 1; | 238 | idx = context - 1; |
241 | if (fpriv && | 239 | if (fpriv && |
242 | context != DRM_KERNEL_CONTEXT && | 240 | context != DRM_KERNEL_CONTEXT && fpriv->hw_state[idx] != NULL) { |
243 | fpriv->hw_state[idx] != NULL) { | ||
244 | kfree(fpriv->hw_state[idx]); | 241 | kfree(fpriv->hw_state[idx]); |
245 | fpriv->hw_state[idx] = NULL; | 242 | fpriv->hw_state[idx] = NULL; |
246 | } | 243 | } |
247 | } | 244 | } |
248 | 245 | ||
249 | static void ffb_driver_pretakedown(drm_device_t *dev) | 246 | static void ffb_driver_pretakedown(drm_device_t * dev) |
250 | { | 247 | { |
251 | if (dev->dev_private) kfree(dev->dev_private); | 248 | if (dev->dev_private) |
249 | kfree(dev->dev_private); | ||
252 | } | 250 | } |
253 | 251 | ||
254 | static int ffb_driver_postcleanup(drm_device_t *dev) | 252 | static int ffb_driver_postcleanup(drm_device_t * dev) |
255 | { | 253 | { |
256 | if (ffb_position != NULL) kfree(ffb_position); | 254 | if (ffb_position != NULL) |
255 | kfree(ffb_position); | ||
257 | return 0; | 256 | return 0; |
258 | } | 257 | } |
259 | 258 | ||
260 | static void ffb_driver_kernel_context_switch_unlock(struct drm_device *dev, drm_lock_t *lock) | 259 | static void ffb_driver_kernel_context_switch_unlock(struct drm_device *dev, |
260 | drm_lock_t * lock) | ||
261 | { | 261 | { |
262 | dev->lock.filp = 0; | 262 | dev->lock.filp = 0; |
263 | { | 263 | { |
264 | __volatile__ unsigned int *plock = &dev->lock.hw_lock->lock; | 264 | __volatile__ unsigned int *plock = &dev->lock.hw_lock->lock; |
265 | unsigned int old, new, prev, ctx; | 265 | unsigned int old, new, prev, ctx; |
266 | 266 | ||
267 | ctx = lock->context; | 267 | ctx = lock->context; |
268 | do { | 268 | do { |
269 | old = *plock; | 269 | old = *plock; |
270 | new = ctx; | 270 | new = ctx; |
271 | prev = cmpxchg(plock, old, new); | 271 | prev = cmpxchg(plock, old, new); |
272 | } while (prev != old); | 272 | } while (prev != old); |
273 | } | 273 | } |
274 | wake_up_interruptible(&dev->lock.lock_queue); | 274 | wake_up_interruptible(&dev->lock.lock_queue); |
275 | } | 275 | } |
276 | 276 | ||
277 | static unsigned long ffb_driver_get_map_ofs(drm_map_t *map) | 277 | static unsigned long ffb_driver_get_map_ofs(drm_map_t * map) |
278 | { | 278 | { |
279 | return (map->offset & 0xffffffff); | 279 | return (map->offset & 0xffffffff); |
280 | } | 280 | } |
281 | 281 | ||
282 | static unsigned long ffb_driver_get_reg_ofs(drm_device_t *dev) | 282 | static unsigned long ffb_driver_get_reg_ofs(drm_device_t * dev) |
283 | { | 283 | { |
284 | ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *)dev->dev_private; | 284 | ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *) dev->dev_private; |
285 | 285 | ||
286 | if (ffb_priv) | 286 | if (ffb_priv) |
287 | return ffb_priv->card_phys_base; | 287 | return ffb_priv->card_phys_base; |
288 | 288 | ||
289 | return 0; | 289 | return 0; |
290 | } | 290 | } |
291 | 291 | ||
292 | static int postinit( struct drm_device *dev, unsigned long flags ) | 292 | static int postinit(struct drm_device *dev, unsigned long flags) |
293 | { | 293 | { |
294 | DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n", | 294 | DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", |
295 | DRIVER_NAME, | 295 | DRIVER_NAME, |
296 | DRIVER_MAJOR, | 296 | DRIVER_MAJOR, |
297 | DRIVER_MINOR, | 297 | DRIVER_MINOR, DRIVER_PATCHLEVEL, DRIVER_DATE, dev->minor); |
298 | DRIVER_PATCHLEVEL, | ||
299 | DRIVER_DATE, | ||
300 | dev->minor | ||
301 | ); | ||
302 | return 0; | 298 | return 0; |
303 | } | 299 | } |
304 | 300 | ||
305 | static int version( drm_version_t *version ) | 301 | static int version(drm_version_t * version) |
306 | { | 302 | { |
307 | int len; | 303 | int len; |
308 | 304 | ||
309 | version->version_major = DRIVER_MAJOR; | 305 | version->version_major = DRIVER_MAJOR; |
310 | version->version_minor = DRIVER_MINOR; | 306 | version->version_minor = DRIVER_MINOR; |
311 | version->version_patchlevel = DRIVER_PATCHLEVEL; | 307 | version->version_patchlevel = DRIVER_PATCHLEVEL; |
312 | DRM_COPY( version->name, DRIVER_NAME ); | 308 | DRM_COPY(version->name, DRIVER_NAME); |
313 | DRM_COPY( version->date, DRIVER_DATE ); | 309 | DRM_COPY(version->date, DRIVER_DATE); |
314 | DRM_COPY( version->desc, DRIVER_DESC ); | 310 | DRM_COPY(version->desc, DRIVER_DESC); |
315 | return 0; | 311 | return 0; |
316 | } | 312 | } |
317 | 313 | ||
318 | static drm_ioctl_desc_t ioctls[] = { | 314 | static drm_ioctl_desc_t ioctls[] = { |
319 | 315 | ||
320 | }; | 316 | }; |
321 | 317 | ||
322 | static struct drm_driver driver = { | 318 | static struct drm_driver driver = { |
@@ -335,14 +331,15 @@ static struct drm_driver driver = { | |||
335 | .ioctls = ioctls, | 331 | .ioctls = ioctls, |
336 | .num_ioctls = DRM_ARRAY_SIZE(ioctls), | 332 | .num_ioctls = DRM_ARRAY_SIZE(ioctls), |
337 | .fops = { | 333 | .fops = { |
338 | .owner = THIS_MODULE, | 334 | .owner = THIS_MODULE, |
339 | .open = drm_open, | 335 | .open = drm_open, |
340 | .release = drm_release, | 336 | .release = drm_release, |
341 | .ioctl = drm_ioctl, | 337 | .ioctl = drm_ioctl, |
342 | .mmap = drm_mmap, | 338 | .mmap = drm_mmap, |
343 | .poll = drm_poll, | 339 | .poll = drm_poll, |
344 | .fasync = drm_fasync, | 340 | .fasync = drm_fasync, |
345 | }, | 341 | } |
342 | , | ||
346 | }; | 343 | }; |
347 | 344 | ||
348 | static int __init ffb_init(void) | 345 | static int __init ffb_init(void) |
@@ -357,6 +354,6 @@ static void __exit ffb_exit(void) | |||
357 | module_init(ffb_init); | 354 | module_init(ffb_init); |
358 | module_exit(ffb_exit); | 355 | module_exit(ffb_exit); |
359 | 356 | ||
360 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 357 | MODULE_AUTHOR(DRIVER_AUTHOR); |
361 | MODULE_DESCRIPTION( DRIVER_DESC ); | 358 | MODULE_DESCRIPTION(DRIVER_DESC); |
362 | MODULE_LICENSE("GPL and additional rights"); | 359 | MODULE_LICENSE("GPL and additional rights"); |