~ubuntu-branches/ubuntu/saucy/linux-ti-omap4/saucy-proposed

« back to all changes in this revision

Viewing changes to drivers/tty/vt/consolemap.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati, Stefan Bader, Upstream Kernel Changes
  • Date: 2012-08-15 17:17:43 UTC
  • Revision ID: package-import@ubuntu.com-20120815171743-h5wnuf51xe7pvdid
Tags: 3.5.0-207.13
[ Paolo Pisati ]

* Start new release

[ Stefan Bader ]

* (config) Enable getabis to use local package copies

[ Upstream Kernel Changes ]

* fixup: gargabe collect iva_seq[0|1] init
* [Config] enable all SND_OMAP_SOC_*s
* fixup: cm2xxx_3xxx.o is needed for omap2_cm_read|write_reg
* fixup: add some snd_soc_dai* helper functions
* fixup: s/snd_soc_dpcm_params/snd_soc_dpcm/g
* fixup: typo, no_host_mode and useless SDP4430 init
* fixup: enable again aess hwmod

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include <linux/init.h>
20
20
#include <linux/tty.h>
21
21
#include <asm/uaccess.h>
 
22
#include <linux/console.h>
22
23
#include <linux/consolemap.h>
23
24
#include <linux/vt_kern.h>
24
25
 
312
313
        if (!access_ok(VERIFY_READ, arg, E_TABSZ))
313
314
                return -EFAULT;
314
315
 
 
316
        console_lock();
315
317
        for (i=0; i<E_TABSZ ; i++) {
316
318
                unsigned char uc;
317
319
                __get_user(uc, arg+i);
319
321
        }
320
322
 
321
323
        update_user_maps();
 
324
        console_unlock();
322
325
        return 0;
323
326
}
324
327
 
330
333
        if (!access_ok(VERIFY_WRITE, arg, E_TABSZ))
331
334
                return -EFAULT;
332
335
 
 
336
        console_lock();
333
337
        for (i=0; i<E_TABSZ ; i++)
334
 
          {
335
 
            ch = conv_uni_to_pc(vc_cons[fg_console].d, p[i]);
336
 
            __put_user((ch & ~0xff) ? 0 : ch, arg+i);
337
 
          }
 
338
        {
 
339
                ch = conv_uni_to_pc(vc_cons[fg_console].d, p[i]);
 
340
                __put_user((ch & ~0xff) ? 0 : ch, arg+i);
 
341
        }
 
342
        console_unlock();
338
343
        return 0;
339
344
}
340
345
 
346
351
        if (!access_ok(VERIFY_READ, arg, E_TABSZ*sizeof(unsigned short)))
347
352
                return -EFAULT;
348
353
 
 
354
        console_lock();
349
355
        for (i=0; i<E_TABSZ ; i++) {
350
356
                unsigned short us;
351
357
                __get_user(us, arg+i);
353
359
        }
354
360
 
355
361
        update_user_maps();
 
362
        console_unlock();
356
363
        return 0;
357
364
}
358
365
 
364
371
        if (!access_ok(VERIFY_WRITE, arg, E_TABSZ*sizeof(unsigned short)))
365
372
                return -EFAULT;
366
373
 
 
374
        console_lock();
367
375
        for (i=0; i<E_TABSZ ; i++)
368
376
          __put_user(p[i], arg+i);
 
377
        console_unlock();
369
378
        
370
379
        return 0;
371
380
}
407
416
        }
408
417
}
409
418
 
 
419
/* Caller must hold the console lock */
410
420
void con_free_unimap(struct vc_data *vc)
411
421
{
412
422
        struct uni_pagedir *p;
487
497
        return 0;
488
498
}
489
499
 
490
 
/* ui is a leftover from using a hashtable, but might be used again */
491
 
int con_clear_unimap(struct vc_data *vc, struct unimapinit *ui)
 
500
/* ui is a leftover from using a hashtable, but might be used again
 
501
   Caller must hold the lock */
 
502
static int con_do_clear_unimap(struct vc_data *vc, struct unimapinit *ui)
492
503
{
493
504
        struct uni_pagedir *p, *q;
494
 
  
 
505
 
495
506
        p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
496
 
        if (p && p->readonly) return -EIO;
 
507
        if (p && p->readonly)
 
508
                return -EIO;
 
509
 
497
510
        if (!p || --p->refcount) {
498
511
                q = kzalloc(sizeof(*p), GFP_KERNEL);
499
512
                if (!q) {
500
 
                        if (p) p->refcount++;
 
513
                        if (p)
 
514
                                p->refcount++;
501
515
                        return -ENOMEM;
502
516
                }
503
517
                q->refcount=1;
511
525
        return 0;
512
526
}
513
527
 
 
528
int con_clear_unimap(struct vc_data *vc, struct unimapinit *ui)
 
529
{
 
530
        int ret;
 
531
        console_lock();
 
532
        ret = con_do_clear_unimap(vc, ui);
 
533
        console_unlock();
 
534
        return ret;
 
535
}
 
536
        
514
537
int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
515
538
{
516
539
        int err = 0, err1, i;
517
540
        struct uni_pagedir *p, *q;
518
541
 
 
542
        console_lock();
 
543
 
519
544
        /* Save original vc_unipagdir_loc in case we allocate a new one */
520
545
        p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
521
 
        if (p->readonly) return -EIO;
 
546
        if (p->readonly) {
 
547
                console_unlock();
 
548
                return -EIO;
 
549
        }
522
550
        
523
 
        if (!ct) return 0;
 
551
        if (!ct) {
 
552
                console_unlock();
 
553
                return 0;
 
554
        }
524
555
        
525
556
        if (p->refcount > 1) {
526
557
                int j, k;
527
558
                u16 **p1, *p2, l;
528
559
                
529
 
                err1 = con_clear_unimap(vc, NULL);
530
 
                if (err1) return err1;
 
560
                err1 = con_do_clear_unimap(vc, NULL);
 
561
                if (err1) {
 
562
                        console_unlock();
 
563
                        return err1;
 
564
                }
531
565
                
532
566
                /*
533
567
                 * Since refcount was > 1, con_clear_unimap() allocated a
558
592
                                                *vc->vc_uni_pagedir_loc = (unsigned long)p;
559
593
                                                con_release_unimap(q);
560
594
                                                kfree(q);
561
 
                                                return err1;
 
595
                                                console_unlock();
 
596
                                                return err1; 
562
597
                                        }
563
598
                                }
564
599
                        } else {
592
627
        /*
593
628
         * Merge with fontmaps of any other virtual consoles.
594
629
         */
595
 
        if (con_unify_unimap(vc, p))
 
630
        if (con_unify_unimap(vc, p)) {
 
631
                console_unlock();
596
632
                return err;
 
633
        }
597
634
 
598
635
        for (i = 0; i <= 3; i++)
599
636
                set_inverse_transl(vc, p, i); /* Update inverse translations */
600
637
        set_inverse_trans_unicode(vc, p);
601
 
  
 
638
 
 
639
        console_unlock();
602
640
        return err;
603
641
}
604
642
 
605
 
/* Loads the unimap for the hardware font, as defined in uni_hash.tbl.
606
 
   The representation used was the most compact I could come up
607
 
   with.  This routine is executed at sys_setup time, and when the
608
 
   PIO_FONTRESET ioctl is called. */
609
 
 
 
643
/**
 
644
 *      con_set_default_unimap  -       set default unicode map
 
645
 *      @vc: the console we are updating
 
646
 *
 
647
 *      Loads the unimap for the hardware font, as defined in uni_hash.tbl.
 
648
 *      The representation used was the most compact I could come up
 
649
 *      with.  This routine is executed at video setup, and when the
 
650
 *      PIO_FONTRESET ioctl is called. 
 
651
 *
 
652
 *      The caller must hold the console lock
 
653
 */
610
654
int con_set_default_unimap(struct vc_data *vc)
611
655
{
612
656
        int i, j, err = 0, err1;
617
661
                p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
618
662
                if (p == dflt)
619
663
                        return 0;
 
664
 
620
665
                dflt->refcount++;
621
666
                *vc->vc_uni_pagedir_loc = (unsigned long)dflt;
622
667
                if (p && !--p->refcount) {
628
673
        
629
674
        /* The default font is always 256 characters */
630
675
 
631
 
        err = con_clear_unimap(vc, NULL);
632
 
        if (err) return err;
 
676
        err = con_do_clear_unimap(vc, NULL);
 
677
        if (err)
 
678
                return err;
633
679
    
634
680
        p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
635
681
        q = dfont_unitable;
654
700
}
655
701
EXPORT_SYMBOL(con_set_default_unimap);
656
702
 
 
703
/**
 
704
 *      con_copy_unimap         -       copy unimap between two vts
 
705
 *      @dst_vc: target
 
706
 *      @src_vt: source
 
707
 *
 
708
 *      The caller must hold the console lock when invoking this method
 
709
 */
657
710
int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc)
658
711
{
659
712
        struct uni_pagedir *q;
668
721
        *dst_vc->vc_uni_pagedir_loc = (long)q;
669
722
        return 0;
670
723
}
 
724
EXPORT_SYMBOL(con_copy_unimap);
671
725
 
 
726
/**
 
727
 *      con_get_unimap          -       get the unicode map
 
728
 *      @vc: the console to read from
 
729
 *
 
730
 *      Read the console unicode data for this console. Called from the ioctl
 
731
 *      handlers.
 
732
 */
672
733
int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct unipair __user *list)
673
734
{
674
735
        int i, j, k, ect;
675
736
        u16 **p1, *p2;
676
737
        struct uni_pagedir *p;
677
738
 
 
739
        console_lock();
 
740
 
678
741
        ect = 0;
679
742
        if (*vc->vc_uni_pagedir_loc) {
680
743
                p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
694
757
                                }
695
758
        }
696
759
        __put_user(ect, uct);
 
760
        console_unlock();
697
761
        return ((ect <= ct) ? 0 : -ENOMEM);
698
762
}
699
763
 
700
 
void con_protect_unimap(struct vc_data *vc, int rdonly)
701
 
{
702
 
        struct uni_pagedir *p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
703
 
        
704
 
        if (p)
705
 
                p->readonly = rdonly;
706
 
}
707
 
 
708
764
/*
709
765
 * Always use USER_MAP. These functions are used by the keyboard,
710
766
 * which shouldn't be affected by G0/G1 switching, etc.
711
767
 * If the user map still contains default values, i.e. the
712
768
 * direct-to-font mapping, then assume user is using Latin1.
 
769
 *
 
770
 * FIXME: at some point we need to decide if we want to lock the table
 
771
 * update element itself via the keyboard_event_lock for consistency with the
 
772
 * keyboard driver as well as the consoles
713
773
 */
714
774
/* may be called during an interrupt */
715
775
u32 conv_8bit_to_uni(unsigned char c)
777
837
                        con_set_default_unimap(vc_cons[i].d);
778
838
}
779
839
 
780
 
EXPORT_SYMBOL(con_copy_unimap);