Lines Matching defs:cvt

73 static u32 fb_cvt_hperiod(struct fb_cvt_data *cvt)
75 u32 num = 1000000000/cvt->f_refresh;
78 if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) {
80 den = 2 * (cvt->yres/cvt->interlace + 2 * cvt->v_margin);
83 den = 2 * (cvt->yres/cvt->interlace + cvt->v_margin * 2
84 + FB_CVT_MIN_VPORCH + cvt->interlace/2);
91 static u32 fb_cvt_ideal_duty_cycle(struct fb_cvt_data *cvt)
96 u32 h_period_est = cvt->hperiod;
101 static u32 fb_cvt_hblank(struct fb_cvt_data *cvt)
105 if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK)
108 u32 ideal_duty_cycle = fb_cvt_ideal_duty_cycle(cvt);
109 u32 active_pixels = cvt->active_pixels;
125 static u32 fb_cvt_hsync(struct fb_cvt_data *cvt)
129 if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK)
132 hsync = (FB_CVT_CELLSIZE * cvt->htotal)/100;
138 static u32 fb_cvt_vbi_lines(struct fb_cvt_data *cvt)
142 if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) {
143 vbi_lines = (1000 * FB_CVT_RB_MIN_VBLANK)/cvt->hperiod + 1;
144 min_vbi_lines = FB_CVT_RB_V_FPORCH + cvt->vsync +
148 vbi_lines = (FB_CVT_MIN_VSYNC_BP * 1000)/cvt->hperiod + 1 +
150 min_vbi_lines = cvt->vsync + FB_CVT_MIN_BPORCH +
162 static u32 fb_cvt_vtotal(struct fb_cvt_data *cvt)
164 u32 vtotal = cvt->yres/cvt->interlace;
166 vtotal += 2 * cvt->v_margin + cvt->interlace/2 + fb_cvt_vbi_lines(cvt);
167 vtotal |= cvt->interlace/2;
172 static u32 fb_cvt_pixclock(struct fb_cvt_data *cvt)
176 if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK)
177 pixclock = (cvt->f_refresh * cvt->vtotal * cvt->htotal)/1000;
179 pixclock = (cvt->htotal * 1000000)/cvt->hperiod;
188 static u32 fb_cvt_aspect_ratio(struct fb_cvt_data *cvt)
190 u32 xres = cvt->xres;
191 u32 yres = cvt->yres;
208 cvt->status = 1;
214 static void fb_cvt_print_name(struct fb_cvt_data *cvt)
225 pixcount = (cvt->xres * (cvt->yres/cvt->interlace))/1000000;
226 pixcount_mod = (cvt->xres * (cvt->yres/cvt->interlace)) % 1000000;
230 cvt->xres, cvt->yres, cvt->refresh);
232 if (cvt->status) {
242 if (cvt->aspect_ratio == 0)
244 else if (cvt->aspect_ratio == 3)
246 else if (cvt->aspect_ratio == 1 || cvt->aspect_ratio == 4)
248 else if (cvt->aspect_ratio == 2)
251 if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK)
259 static void fb_cvt_convert_to_mode(struct fb_cvt_data *cvt,
262 mode->refresh = cvt->f_refresh;
263 mode->pixclock = KHZ2PICOS(cvt->pixclock/1000);
264 mode->left_margin = cvt->h_back_porch;
265 mode->right_margin = cvt->h_front_porch;
266 mode->hsync_len = cvt->hsync;
267 mode->upper_margin = cvt->v_back_porch;
268 mode->lower_margin = cvt->v_front_porch;
269 mode->vsync_len = cvt->vsync;
273 if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK)
296 struct fb_cvt_data cvt;
298 memset(&cvt, 0, sizeof(cvt));
301 cvt.flags |= FB_CVT_FLAG_MARGINS;
304 cvt.flags |= FB_CVT_FLAG_REDUCED_BLANK;
307 cvt.flags |= FB_CVT_FLAG_INTERLACED;
309 cvt.xres = mode->xres;
310 cvt.yres = mode->yres;
311 cvt.refresh = mode->refresh;
312 cvt.f_refresh = cvt.refresh;
313 cvt.interlace = 1;
315 if (!cvt.xres || !cvt.yres || !cvt.refresh || cvt.f_refresh > INT_MAX) {
320 if (!(cvt.refresh == 50 || cvt.refresh == 60 || cvt.refresh == 70 ||
321 cvt.refresh == 85)) {
324 cvt.status = 1;
327 cvt.xres &= ~(FB_CVT_CELLSIZE - 1);
329 if (cvt.flags & FB_CVT_FLAG_INTERLACED) {
330 cvt.interlace = 2;
331 cvt.f_refresh *= 2;
334 if (cvt.flags & FB_CVT_FLAG_REDUCED_BLANK) {
335 if (cvt.refresh != 60) {
338 cvt.status = 1;
342 if (cvt.flags & FB_CVT_FLAG_MARGINS) {
343 cvt.h_margin = (cvt.xres * 18)/1000;
344 cvt.h_margin &= ~(FB_CVT_CELLSIZE - 1);
345 cvt.v_margin = ((cvt.yres/cvt.interlace)* 18)/1000;
348 cvt.aspect_ratio = fb_cvt_aspect_ratio(&cvt);
349 cvt.active_pixels = cvt.xres + 2 * cvt.h_margin;
350 cvt.hperiod = fb_cvt_hperiod(&cvt);
351 cvt.vsync = fb_cvt_vbi_tab[cvt.aspect_ratio];
352 cvt.vtotal = fb_cvt_vtotal(&cvt);
353 cvt.hblank = fb_cvt_hblank(&cvt);
354 cvt.htotal = cvt.active_pixels + cvt.hblank;
355 cvt.hsync = fb_cvt_hsync(&cvt);
356 cvt.pixclock = fb_cvt_pixclock(&cvt);
357 cvt.hfreq = cvt.pixclock/cvt.htotal;
358 cvt.h_back_porch = cvt.hblank/2 + cvt.h_margin;
359 cvt.h_front_porch = cvt.hblank - cvt.hsync - cvt.h_back_porch +
360 2 * cvt.h_margin;
361 cvt.v_front_porch = 3 + cvt.v_margin;
362 cvt.v_back_porch = cvt.vtotal - cvt.yres/cvt.interlace -
363 cvt.v_front_porch - cvt.vsync;
364 fb_cvt_print_name(&cvt);
365 fb_cvt_convert_to_mode(&cvt, mode);