Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 204428 | Differences between
and this patch

Collapse All | Expand All

(-)nvclock/src/backend/nv40.c (+24 lines)
Lines 430-435 Link Here
430
	nv_card->PMC[0x15f0/4] = (level << 16) | (nv_card->PMC[0x15f0/4] & 0xffe0ffff);
430
	nv_card->PMC[0x15f0/4] = (level << 16) | (nv_card->PMC[0x15f0/4] & 0xffe0ffff);
431
}
431
}
432
432
433
/* Fade backpanel brightness on laptops */
434
void nv44_mobile_fade_smartdimmer(int end, unsigned long delay)
435
{
436
	int i, start = nv_card->get_smartdimmer();
437
438
	if (end < 15)
439
		end = 15;
440
	if (end > 100)
441
		end = 100;
442
443
	if (end >= start) {
444
		for (i = start + 1; i <= end; i++) {
445
			nv_card->set_smartdimmer(i);
446
			usleep(delay);
447
		}
448
	} else {
449
		for (i = start - 1; i >= end; i--) {
450
			nv_card->set_smartdimmer(i);
451
			usleep(delay);
452
		}
453
	}
454
}
455
433
static int CalcSpeed_nv40(int base_freq, int m1, int m2, int n1, int n2, int p)
456
static int CalcSpeed_nv40(int base_freq, int m1, int m2, int n1, int n2, int p)
434
{
457
{
435
	return (int)((float)(n1*n2)/(m1*m2) * base_freq) >> p;
458
	return (int)((float)(n1*n2)/(m1*m2) * base_freq) >> p;
Lines 1022-1027 Link Here
1022
		nv_card->caps |= SMARTDIMMER;
1045
		nv_card->caps |= SMARTDIMMER;
1023
		nv_card->get_smartdimmer = nv44_mobile_get_smartdimmer;
1046
		nv_card->get_smartdimmer = nv44_mobile_get_smartdimmer;
1024
		nv_card->set_smartdimmer = nv44_mobile_set_smartdimmer;
1047
		nv_card->set_smartdimmer = nv44_mobile_set_smartdimmer;
1048
		nv_card->fade_smartdimmer = nv44_mobile_fade_smartdimmer;
1025
	}
1049
	}
1026
	
1050
	
1027
	/* Temperature monitoring; all cards after the NV40 feature an internal temperature sensor.
1051
	/* Temperature monitoring; all cards after the NV40 feature an internal temperature sensor.
(-)nvclock/src/backend/nv50.c (+23 lines)
Lines 253-258 Link Here
253
	nv_card->PDISPLAY[NV_PDISPLAY_SOR0_REGS_BRIGHTNESS/4] = val;
253
	nv_card->PDISPLAY[NV_PDISPLAY_SOR0_REGS_BRIGHTNESS/4] = val;
254
}
254
}
255
255
256
/* Fade backpanel brightness on laptops */
257
void nv50_mobile_fade_smartdimmer(int end, unsigned long delay) {
258
	int i, start = nv_card->get_smartdimmer();
259
260
	if (end < 15)
261
		end = 15;
262
	if (end > 100)
263
		end = 100;
264
265
	if (end >= start) {
266
		for (i = start + 1; i <= end; i++) {
267
			nv_card->set_smartdimmer(i);
268
			usleep(delay);
269
		}
270
	} else {
271
		for (i = start - 1; i >= end; i--) {
272
			nv_card->set_smartdimmer(i);
273
			usleep(delay);
274
		}
275
	}
276
}
277
256
static int CalcSpeed_nv50(int base_freq, int m1, int m2, int n1, int n2, int p)
278
static int CalcSpeed_nv50(int base_freq, int m1, int m2, int n1, int n2, int p)
257
{
279
{
258
	return (int)((float)(n1*n2)/(m1*m2) * base_freq) >> p;
280
	return (int)((float)(n1*n2)/(m1*m2) * base_freq) >> p;
Lines 414-419 Link Here
414
		nv_card->caps |= SMARTDIMMER;
436
		nv_card->caps |= SMARTDIMMER;
415
		nv_card->get_smartdimmer = nv50_mobile_get_smartdimmer;
437
		nv_card->get_smartdimmer = nv50_mobile_get_smartdimmer;
416
		nv_card->set_smartdimmer = nv50_mobile_set_smartdimmer;
438
		nv_card->set_smartdimmer = nv50_mobile_set_smartdimmer;
439
		nv_card->fade_smartdimmer = nv50_mobile_fade_smartdimmer;
417
	}
440
	}
418
441
419
	/* Temperature monitoring; all NV50 cards feature an internal temperature sensor
442
	/* Temperature monitoring; all NV50 cards feature an internal temperature sensor
(-)nvclock/src/backend/nvclock.h (+1 lines)
Lines 280-285 Link Here
280
	/* Smartdimmer (adjustment of the brigthenss of the backlight on Laptops) */
280
	/* Smartdimmer (adjustment of the brigthenss of the backlight on Laptops) */
281
	int (*get_smartdimmer)();
281
	int (*get_smartdimmer)();
282
	void (*set_smartdimmer)(int level);
282
	void (*set_smartdimmer)(int level);
283
	void (*fade_smartdimmer)(int level, unsigned long delay);
283
284
284
	/* Overclocking */
285
	/* Overclocking */
285
	volatile unsigned int mpll; /* default memory speed */
286
	volatile unsigned int mpll; /* default memory speed */
(-)nvclock/src/smartdimmer.c (-1 / +31 lines)
Lines 45-54 Link Here
45
#define GET_BIT    2
45
#define GET_BIT    2
46
#define INC_BIT    4
46
#define INC_BIT    4
47
#define DEC_BIT    8
47
#define DEC_BIT    8
48
#define FAD_BIT    16
49
#define DEL_BIT    32
48
50
49
static struct option long_opts[] = {
51
static struct option long_opts[] = {
50
    { "get"     , no_argument      , 0, 'g' },
52
    { "get"     , no_argument      , 0, 'g' },
51
    { "set"     , required_argument, 0, 's' },
53
    { "set"     , required_argument, 0, 's' },
54
    { "fade"    , required_argument, 0, 'f' },
55
    { "delay"   , required_argument, 0, 'e' },
52
    { "increase", no_argument      , 0, 'i' },
56
    { "increase", no_argument      , 0, 'i' },
53
    { "decrease", no_argument      , 0, 'd' },
57
    { "decrease", no_argument      , 0, 'd' },
54
    { "help"    , no_argument      , 0, 'h' },
58
    { "help"    , no_argument      , 0, 'h' },
Lines 62-67 Link Here
62
    printf("Options:\n");
66
    printf("Options:\n");
63
    printf("\t-g  --get\t\tQuery brightness level.\n");
67
    printf("\t-g  --get\t\tQuery brightness level.\n");
64
    printf("\t-s  --set <level>\tSet brightness level (15-100)\n");
68
    printf("\t-s  --set <level>\tSet brightness level (15-100)\n");
69
    printf("\t-f  --fade <level>\tFade in/out to brightness level (15-100)\n");
70
    printf("\t-e  --delay <level>\tFade cycle delay (usecs)\n");
65
    printf("\t-i  --increase\t\tIncrease brightness with one level.\n");
71
    printf("\t-i  --increase\t\tIncrease brightness with one level.\n");
66
    printf("\t-d  --decrease\t\tDecrease brightness with one level.\n");
72
    printf("\t-d  --decrease\t\tDecrease brightness with one level.\n");
67
    printf("\t-h  --help\t\tPrints this help text.\n\n");
73
    printf("\t-h  --help\t\tPrints this help text.\n\n");
Lines 83-88 Link Here
83
{   
89
{   
84
    int optind = 0, options = 0, setvalue = 0;
90
    int optind = 0, options = 0, setvalue = 0;
85
    int c;
91
    int c;
92
	unsigned long delay = 7000;
86
    
93
    
87
    if (argc < 2)
94
    if (argc < 2)
88
    {
95
    {
Lines 90-96 Link Here
90
        return 0;
97
        return 0;
91
    }
98
    }
92
    
99
    
93
    while ((c = getopt_long(argc, argv, "gs:idh", long_opts, &optind)) != -1)
100
    while ((c = getopt_long(argc, argv, "gs:f:e:idh", long_opts, &optind)) != -1)
94
    {
101
    {
95
        switch (c)
102
        switch (c)
96
        {
103
        {
Lines 113-118 Link Here
113
                   return 1;
120
                   return 1;
114
               }
121
               }
115
               break;
122
               break;
123
            case 'f':
124
               if (isdigit(*optarg)) {
125
                   setvalue = atoi(optarg);
126
                   options |= FAD_BIT;
127
               } else {
128
                   fprintf(stderr, "Illegal option value (-f): "
129
                           "Value has to be a non-negative number.\n");
130
                   return 1;
131
               }
132
               break;
133
            case 'e':
134
               if (isdigit(*optarg)) {
135
                   delay = atoi(optarg);
136
                   options |= DEL_BIT;
137
               } else {
138
                   fprintf(stderr, "Illegal option value (-d): "
139
                           "Value has to be a non-negative number.\n");
140
                   return 1;
141
               }
142
               break;
116
            case 'i':
143
            case 'i':
117
               options |= INC_BIT;
144
               options |= INC_BIT;
118
               break;
145
               break;
Lines 154-159 Link Here
154
    if (options & SET_BIT)
181
    if (options & SET_BIT)
155
        nv_card->set_smartdimmer(setvalue);
182
        nv_card->set_smartdimmer(setvalue);
156
    
183
    
184
    if (options & FAD_BIT)
185
        nv_card->fade_smartdimmer(setvalue, delay);
186
157
    if (options & GET_BIT)
187
    if (options & GET_BIT)
158
        printf("SmartDimmer level: %d\n", nv_card->get_smartdimmer());
188
        printf("SmartDimmer level: %d\n", nv_card->get_smartdimmer());
159
    
189
    

Return to bug 204428