aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/pad/pad/pad.c
blob: e81e22504d727d9fd7b040e905898b1abe7ef3db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

int stat(const char *file_name, struct stat *buf);

int syntax(void)
{
  printf("syntax:\n");
  printf("  pad padnum filename\n");
  return(0);
}

int main(int argc, char **argv)
{
  FILE *fp;
  long int i=0L, padsize=0L;
  unsigned char data=0xff;
  struct stat fileinfo;
  if(argc<3){
    syntax();
    exit(1);
  }
  if((fp=fopen(argv[2],"a"))==NULL){
    printf("error opening %s.\n",argv[2]);
    exit(1);
  }
  if(stat(argv[2],&fileinfo)!=0){
    printf("error in stat of %s.\n",argv[2]);
    exit(1);
  }
  padsize = strtol(argv[1],NULL,10) - fileinfo.st_size;
  for(i=0;i<padsize;i++){
    fwrite(&data,1,1,fp);
  }
  fclose(fp);
  return(0);
}
x24382400, 0x00000000 }, + { 0x28371FFE, 0x28391F04, 0x000004FE }, + { 0x2C361BFB, 0x2D381B08, 0x000008FB }, + { 0x303516F9, 0x3237170C, 0x00000CF9 }, + { 0x11343311, 0x123737F7, 0x0000F711 }, + { 0x1635300C, 0x173732F9, 0x0000F90C }, + { 0x1B362C08, 0x1B382DFB, 0x0000FB08 }, + { 0x1F372804, 0x1F3928FE, 0x0000FE04 }, + }; + int i; + + for (i = 0; i < 8; i++) { + write_firh_reg(plane, i, coef[i][0]); + write_firhv_reg(plane, i, coef[i][1]); + write_firv_reg(plane, i, coef[i][2]); + } +} + static int omap_dispc_set_scale(int plane, int orig_width, int orig_height, int out_width, int out_height) @@ -592,25 +626,47 @@ static int omap_dispc_set_scale(int plane, if (orig_height > out_height || orig_width * 8 < out_width || orig_height * 8 < out_height) { + dev_dbg(dispc.fbdev->dev, + "Max upsampling is 8x, " + "tried: %dx%d -> %dx%d\n", + orig_width, orig_height, + out_width, out_height); enable_lcd_clocks(0); return -EINVAL; } set_upsampling_coef_table(plane); } else if (orig_width > out_width) { - /* Downsampling not yet supported - */ - - enable_lcd_clocks(0); - return -EINVAL; + /* + * Downsampling. + * Currently you can only scale both dimensions in one way. + */ + if (orig_height < out_height || + orig_width > out_width * 4|| + orig_height > out_height * 4) { + dev_dbg(dispc.fbdev->dev, + "Max downsampling is 4x, " + "tried: %dx%d -> %dx%d\n", + orig_width, orig_height, + out_width, out_height); + enable_lcd_clocks(0); + return -EINVAL; + } + set_downsampling_coef_table(plane); } if (!orig_width || orig_width == out_width) fir_hinc = 0; else - fir_hinc = 1024 * orig_width / out_width; + fir_hinc = 1024 * (orig_width -1)/ (out_width -1); if (!orig_height || orig_height == out_height) fir_vinc = 0; else - fir_vinc = 1024 * orig_height / out_height; + fir_vinc = 1024 * (orig_height-1) / (out_height -1 ); + + dev_dbg(dispc.fbdev->dev, "out_width %d out_height %d orig_width %d " + "orig_height %d fir_hinc %d fir_vinc %d\n", + out_width, out_height, orig_width, orig_height, + fir_hinc, fir_vinc); + dispc.fir_hinc[plane] = fir_hinc; dispc.fir_vinc[plane] = fir_vinc; @@ -619,11 +675,6 @@ static int omap_dispc_set_scale(int plane, ((fir_vinc & 4095) << 16) | (fir_hinc & 4095)); - dev_dbg(dispc.fbdev->dev, "out_width %d out_height %d orig_width %d " - "orig_height %d fir_hinc %d fir_vinc %d\n", - out_width, out_height, orig_width, orig_height, - fir_hinc, fir_vinc); - MOD_REG_FLD(vs_reg[plane], FLD_MASK(16, 11) | FLD_MASK(0, 11), ((out_height - 1) << 16) | (out_width - 1)); -- 1.5.6.5