The patch titled cirrusfb: drop clock fields from cirrusfb_regs structure has been added to the -mm tree. Its filename is cirrusfb-drop-clock-fields-from-cirrusfb_regs-structure.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: cirrusfb: drop clock fields from cirrusfb_regs structure From: Krzysztof Helt <krzysztof.h1@xxxxx> Move call to pixclock calculation into the cirrusfb_set_par_foo(). It makes copy of clock registers redundant. Simplify clock calculations further. Signed-off-by: Krzysztof Helt <krzysztof.h1@xxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/video/cirrusfb.c | 50 +++++++++++++++---------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff -puN drivers/video/cirrusfb.c~cirrusfb-drop-clock-fields-from-cirrusfb_regs-structure drivers/video/cirrusfb.c --- a/drivers/video/cirrusfb.c~cirrusfb-drop-clock-fields-from-cirrusfb_regs-structure +++ a/drivers/video/cirrusfb.c @@ -327,10 +327,6 @@ static const struct { #endif /* CONFIG_ZORRO */ struct cirrusfb_regs { - long freq; - long nom; - long den; - long div; long multiplexing; long mclk; long divMCLK; @@ -429,9 +425,7 @@ static void cirrusfb_RectFill(u8 __iomem u_short width, u_short height, u_char color, u_short line_length); -static void bestclock(long freq, long *best, - long *nom, long *den, - long *div, long maxfreq); +static void bestclock(long freq, int *nom, int *den, int *div); #ifdef CIRRUSFB_DEBUG static void cirrusfb_dump(void); @@ -711,9 +705,6 @@ static int cirrusfb_decode_var(const str break; } #endif - - bestclock(freq, ®s->freq, ®s->nom, ®s->den, ®s->div, - maxclock); regs->mclk = cirrusfb_get_mclk(freq, var->bits_per_pixel, ®s->divMCLK); @@ -756,6 +747,8 @@ static int cirrusfb_set_par_foo(struct f const struct cirrusfb_board_info_rec *bi; int hdispend, hsyncstart, hsyncend, htotal; int yres, vdispend, vsyncstart, vsyncend, vtotal; + long freq; + int nom, den, div; DPRINTK("ENTER\n"); DPRINTK("Requested mode: %dx%dx%d\n", @@ -903,14 +896,17 @@ static int cirrusfb_set_par_foo(struct f DPRINTK("CRT1a: %d\n", tmp); vga_wcrt(regbase, CL_CRT1A, tmp); + freq = PICOS2KHZ(var->pixclock); + bestclock(freq, &nom, &den, &div); + /* set VCLK0 */ /* hardware RefClock: 14.31818 MHz */ /* formula: VClk = (OSC * N) / (D * (1+P)) */ /* Example: VClk = (14.31818 * 91) / (23 * (1+1)) = 28.325 MHz */ - vga_wseq(regbase, CL_SEQRB, regs.nom); - tmp = regs.den << 1; - if (regs.div != 0) + vga_wseq(regbase, CL_SEQRB, nom); + tmp = den << 1; + if (div != 0) tmp |= 1; /* 6 bit denom; ONLY 5434!!! (bugged me 10 days) */ @@ -2923,16 +2919,14 @@ static void cirrusfb_RectFill(u8 __iomem * bestclock() - determine closest possible clock lower(?) than the * desired pixel clock **************************************************************************/ -static void bestclock(long freq, long *best, long *nom, - long *den, long *div, long maxfreq) +static void bestclock(long freq, int *nom, int *den, int *div) { - long n, h, d, f; + int n, d; + long h, diff; - assert(best != NULL); assert(nom != NULL); assert(den != NULL); assert(div != NULL); - assert(maxfreq > 0); *nom = 0; *den = 0; @@ -2943,16 +2937,12 @@ static void bestclock(long freq, long *b if (freq < 8000) freq = 8000; - if (freq > maxfreq) - freq = maxfreq; - - *best = 0; - f = freq * 10; + diff = freq; for (n = 32; n < 128; n++) { int s = 0; - d = (143181 * n) / f; + d = (14318 * n) / freq; if ((d >= 7) && (d <= 63)) { int temp = d; @@ -2961,8 +2951,9 @@ static void bestclock(long freq, long *b temp >>= 1; } h = ((14318 * n) / temp) >> s; - if (abs(h - freq) < abs(*best - freq)) { - *best = h; + h = h > freq ? h - freq : freq - h; + if (h < diff) { + diff = h; *nom = n; *den = temp; *div = s; @@ -2975,8 +2966,9 @@ static void bestclock(long freq, long *b d >>= 1; } h = ((14318 * n) / d) >> s; - if (abs(h - freq) < abs(*best - freq)) { - *best = h; + h = h > freq ? h - freq : freq - h; + if (h < diff) { + diff = h; *nom = n; *den = d; *div = s; @@ -2985,7 +2977,7 @@ static void bestclock(long freq, long *b } DPRINTK("Best possible values for given frequency:\n"); - DPRINTK(" best: %ld kHz nom: %ld den: %ld div: %ld\n", + DPRINTK(" freq: %ld kHz nom: %d den: %d div: %d\n", freq, *nom, *den, *div); DPRINTK("EXIT\n"); _ Patches currently in -mm which might be from krzysztof.h1@xxxxx are origin.patch atmel_lcdfb-fix-oops-in-rmmod-when-framebuffer-fails-to-register.patch linux-next.patch fb-metronome-printk-format-warning.patch x86-delay-early-cpu-initialization-until-cpuid-is-done.patch x86-move-mtrr-cpu-cap-setting-early-in-early_init_xxxx.patch fb-convert-lock-unlock_kernel-into-local-fb-mutex.patch neofb-reduce-panning-function.patch viafb-accelc-accelh-update.patch viafb-viafbdevc-update.patch fbdev-kconfig-update.patch fbdev-kconfig-update-fix.patch neofb-kill-some-redundant-code.patch vga16fb-remove-open_lock-mutex.patch neofb-remove-open_lock-mutex.patch tdfxfb-do-not-make-changes-to-default-tdfx_fix.patch intelfb-support-945gme-as-used-in-asus-eee-901.patch cirrusfb-remove-information-about-memory-size-during-mode-change.patch cirrusfb-simplify-clock-calculation.patch cirrusfb-remove-24-bpp-mode.patch cirrusfb-drop-device-pointers-from-cirrusfb_info.patch cirrusfb-use-modedb-and-add-mode_option-parameter-2nd-rev.patch cirrusfb-add-__devinit-attribute-to-probing-functions.patch cirrusfb-eliminate-crt-registers-from-global-structure.patch cirrusfb-drop-clock-fields-from-cirrusfb_regs-structure.patch atmel_lcdfb-disallow-setting-larger-resolution-than-the-framebuffer-memory-can-handle.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html