Skip to content

Commit 35480b6

Browse files
moinejfMauro Carvalho Chehab
authored andcommitted
V4L/DVB (9292): gspca: Call the control setting functions at init time in t613.
Signed-off-by: Jean-Francois Moine <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent cbc51c6 commit 35480b6

File tree

1 file changed

+70
-72
lines changed
  • drivers/media/video/gspca

1 file changed

+70
-72
lines changed

drivers/media/video/gspca/t613.c

Lines changed: 70 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,46 @@ static int sd_config(struct gspca_dev *gspca_dev,
502502
return 0;
503503
}
504504

505+
static void setbrightness(struct gspca_dev *gspca_dev)
506+
{
507+
struct sd *sd = (struct sd *) gspca_dev;
508+
unsigned int brightness;
509+
__u8 set6[4] = { 0x8f, 0x24, 0xc3, 0x00 };
510+
511+
brightness = sd->brightness;
512+
if (brightness < 7) {
513+
set6[1] = 0x26;
514+
set6[3] = 0x70 - brightness * 0x10;
515+
} else {
516+
set6[3] = 0x00 + ((brightness - 7) * 0x10);
517+
}
518+
519+
reg_w_buf(gspca_dev, set6, sizeof set6);
520+
}
521+
522+
static void setcontrast(struct gspca_dev *gspca_dev)
523+
{
524+
struct sd *sd = (struct sd *) gspca_dev;
525+
unsigned int contrast = sd->contrast;
526+
__u16 reg_to_write;
527+
528+
if (contrast < 7)
529+
reg_to_write = 0x8ea9 - contrast * 0x200;
530+
else
531+
reg_to_write = 0x00a9 + (contrast - 7) * 0x200;
532+
533+
reg_w(gspca_dev, reg_to_write);
534+
}
535+
536+
static void setcolors(struct gspca_dev *gspca_dev)
537+
{
538+
struct sd *sd = (struct sd *) gspca_dev;
539+
__u16 reg_to_write;
540+
541+
reg_to_write = 0x80bb + sd->colors * 0x100; /* was 0xc0 */
542+
reg_w(gspca_dev, reg_to_write);
543+
}
544+
505545
static void setgamma(struct gspca_dev *gspca_dev)
506546
{
507547
struct sd *sd = (struct sd *) gspca_dev;
@@ -510,6 +550,29 @@ static void setgamma(struct gspca_dev *gspca_dev)
510550
reg_w_buf(gspca_dev, gamma_table[sd->gamma], sizeof gamma_table[0]);
511551
}
512552

553+
static void setwhitebalance(struct gspca_dev *gspca_dev)
554+
{
555+
struct sd *sd = (struct sd *) gspca_dev;
556+
557+
__u8 white_balance[8] =
558+
{0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38};
559+
560+
if (sd->whitebalance)
561+
white_balance[7] = 0x3c;
562+
563+
reg_w_buf(gspca_dev, white_balance, sizeof white_balance);
564+
}
565+
566+
static void setsharpness(struct gspca_dev *gspca_dev)
567+
{
568+
struct sd *sd = (struct sd *) gspca_dev;
569+
__u16 reg_to_write;
570+
571+
reg_to_write = 0x0aa6 + 0x1000 * sd->sharpness;
572+
573+
reg_w(gspca_dev, reg_to_write);
574+
}
575+
513576
/* this function is called at probe and resume time */
514577
static int sd_init(struct gspca_dev *gspca_dev)
515578
{
@@ -551,8 +614,6 @@ static int sd_init(struct gspca_dev *gspca_dev)
551614
0xd5, 0x28, 0xd6, 0x1e, 0xd7, 0x27,
552615
0xd8, 0xc8, 0xd9, 0xfc
553616
};
554-
static const __u8 missing[] =
555-
{ 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 };
556617
static const __u8 nset3[] = {
557618
0xc7, 0x60, 0xc8, 0xa8, 0xc9, 0xe0, 0xca, 0x60, 0xcb, 0xa8,
558619
0xcc, 0xe0, 0xcd, 0x60, 0xce, 0xa8,
@@ -617,15 +678,15 @@ static int sd_init(struct gspca_dev *gspca_dev)
617678
reg_w(gspca_dev, 0x3880);
618679
reg_w(gspca_dev, 0x3880);
619680
reg_w(gspca_dev, 0x338e);
620-
reg_w_buf(gspca_dev, nset5, sizeof nset5);
621-
reg_w(gspca_dev, 0x00a9);
681+
nset5 - missing
682+
setbrightness(gspca_dev);
683+
setcontrast(gspca_dev);
622684
setgamma(gspca_dev);
623-
reg_w(gspca_dev, 0x86bb);
624-
reg_w(gspca_dev, 0x4aa6);
625-
626-
reg_w_buf(gspca_dev, missing, sizeof missing);
685+
setcolors(gspca_dev);
686+
setsharpness(gspca_dev);
687+
setwhitebalance(gspca_dev);
627688

628-
reg_w(gspca_dev, 0x2087);
689+
reg_w(gspca_dev, 0x2087); /* tied to white balance? */
629690
reg_w(gspca_dev, 0x2088);
630691
reg_w(gspca_dev, 0x2089);
631692

@@ -642,23 +703,6 @@ static int sd_init(struct gspca_dev *gspca_dev)
642703
return 0;
643704
}
644705

645-
static void setbrightness(struct gspca_dev *gspca_dev)
646-
{
647-
struct sd *sd = (struct sd *) gspca_dev;
648-
unsigned int brightness;
649-
__u8 set6[4] = { 0x8f, 0x26, 0xc3, 0x00 };
650-
651-
brightness = sd->brightness;
652-
if (brightness < 7) {
653-
set6[3] = 0x70 - brightness * 0x10;
654-
} else {
655-
set6[1] = 0x24;
656-
set6[3] = 0x00 + ((brightness - 7) * 0x10);
657-
}
658-
659-
reg_w_buf(gspca_dev, set6, sizeof set6);
660-
}
661-
662706
static void setflip(struct gspca_dev *gspca_dev)
663707
{
664708
struct sd *sd = (struct sd *) gspca_dev;
@@ -689,19 +733,6 @@ static void seteffect(struct gspca_dev *gspca_dev)
689733
reg_w(gspca_dev, 0xfaa6);
690734
}
691735

692-
static void setwhitebalance(struct gspca_dev *gspca_dev)
693-
{
694-
struct sd *sd = (struct sd *) gspca_dev;
695-
696-
__u8 white_balance[8] =
697-
{ 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 };
698-
699-
if (sd->whitebalance == 1)
700-
white_balance[7] = 0x3c;
701-
702-
reg_w_buf(gspca_dev, white_balance, sizeof white_balance);
703-
}
704-
705736
static void setlightfreq(struct gspca_dev *gspca_dev)
706737
{
707738
struct sd *sd = (struct sd *) gspca_dev;
@@ -713,39 +744,6 @@ static void setlightfreq(struct gspca_dev *gspca_dev)
713744
reg_w_buf(gspca_dev, freq, sizeof freq);
714745
}
715746

716-
static void setcontrast(struct gspca_dev *gspca_dev)
717-
{
718-
struct sd *sd = (struct sd *) gspca_dev;
719-
unsigned int contrast = sd->contrast;
720-
__u16 reg_to_write;
721-
722-
if (contrast < 7)
723-
reg_to_write = 0x8ea9 - (0x200 * contrast);
724-
else
725-
reg_to_write = (0x00a9 + ((contrast - 7) * 0x200));
726-
727-
reg_w(gspca_dev, reg_to_write);
728-
}
729-
730-
static void setcolors(struct gspca_dev *gspca_dev)
731-
{
732-
struct sd *sd = (struct sd *) gspca_dev;
733-
__u16 reg_to_write;
734-
735-
reg_to_write = 0xc0bb + sd->colors * 0x100;
736-
reg_w(gspca_dev, reg_to_write);
737-
}
738-
739-
static void setsharpness(struct gspca_dev *gspca_dev)
740-
{
741-
struct sd *sd = (struct sd *) gspca_dev;
742-
__u16 reg_to_write;
743-
744-
reg_to_write = 0x0aa6 + 0x1000 * sd->sharpness;
745-
746-
reg_w(gspca_dev, reg_to_write);
747-
}
748-
749747
static int sd_start(struct gspca_dev *gspca_dev)
750748
{
751749
struct sd *sd = (struct sd *) gspca_dev;

0 commit comments

Comments
 (0)