Commit b6c24bb9 authored by Andrey Filippov's avatar Andrey Filippov

Window size for JPEG/JP4

parent 447b18ef
......@@ -2005,6 +2005,29 @@ static ssize_t store_endis_chn(struct device *dev, struct device_attribute *attr
// sscanf(buf, "%i", &buffer_settings.frame_start[get_channel_from_name(attr)], &len);
static ssize_t show_fpga_version(struct device *dev, struct device_attribute *attr, char *buf)
{
if (!hardware_initialized)
return -EBUSY;
return sprintf(buf,"0x%08lx\n", x393_fpga_version());
}
static ssize_t show_fpga_sensor_interface(struct device *dev, struct device_attribute *attr, char *buf)
{
if (!hardware_initialized)
return -EBUSY;
switch (x393_sensor_interface()){
case 0:
return sprintf(buf,"PAR12\n");
case 1:
return sprintf(buf,"HISPI\n");
default:
return sprintf(buf,"0x%08%lx\n", x393_sensor_interface());
}
}
static ssize_t show_fpga_time(struct device *dev, struct device_attribute *attr, char *buf)
{
sec_usec_t sec_usec;
......@@ -2085,6 +2108,8 @@ static DEVICE_ATTR(chn_en3, SYSFS_PERMISSIONS, NULL,
static DEVICE_ATTR(all_frames, SYSFS_READONLY, show_all_frames, NULL);
static DEVICE_ATTR(fpga_time, SYSFS_PERMISSIONS, show_fpga_time, store_fpga_time);
static DEVICE_ATTR(fpga_version, SYSFS_READONLY, show_fpga_version, NULL);
static DEVICE_ATTR(fpga_sensor_interface, SYSFS_READONLY, show_fpga_sensor_interface, NULL);
static struct attribute *root_dev_attrs[] = {
&dev_attr_this_frame0.attr,
......@@ -2097,6 +2122,8 @@ static struct attribute *root_dev_attrs[] = {
&dev_attr_chn_en1.attr,
&dev_attr_chn_en2.attr,
&dev_attr_chn_en3.attr,
&dev_attr_fpga_version.attr,
&dev_attr_fpga_sensor_interface.attr,
NULL
};
......
......@@ -1000,6 +1000,7 @@ int mt9x001_pgm_window_common (int sensor_port, ///< sensor port
///< @return 0 - OK, negative - error
{
int i,dv,dh,bv,bh,ww,wh,wl,wt,flip,flipX,flipY,d, v;
int compressor_margin; // 0 for JP4, 2 for JPEG
struct frameparspair_t pars_to_update[29];
int nupdate=0;
int styp = sensor->sensorType & 7;
......@@ -1011,6 +1012,7 @@ int mt9x001_pgm_window_common (int sensor_port, ///< sensor port
bv= thispars->pars[P_BIN_VERT];
ww= thispars->pars[P_SENSOR_PIXH] * dh;
wh= thispars->pars[P_SENSOR_PIXV] * dv;
compressor_margin = (thispars->pars[P_SENSOR_PIXH] - thispars->pars[P_WOI_WIDTH]) >> 1; // assuming same for H and V
flip=((thispars->pars[P_FLIPH] & 1) | ((thispars->pars[P_FLIPV] & 1) << 1 )) ^ sensor->init_flips; // 10338 is _not_ flipped (as the ther boards, but for legacy compatibility....)
flipX = flip & 1;
flipY = (flip & 2)? 1:0;
......@@ -1037,8 +1039,10 @@ int mt9x001_pgm_window_common (int sensor_port, ///< sensor port
dev_dbg(g_dev_ptr,"{%d} SET_SENSOR_MBPAR(0x%x, 0x%x, 0x%x, 0x%x, 0x%x)\n",sensor_port, sensor_port, frame16, (int) sensor->i2c_addr, (int) P_MT9X001_HEIGHT, (int) wh-1);
}
// Margins
wl = thispars->pars[P_WOI_LEFT];
wt = thispars->pars[P_WOI_TOP];
wl = thispars->pars[P_WOI_LEFT] - compressor_margin;
wt = thispars->pars[P_WOI_TOP] - compressor_margin;
dev_dbg(g_dev_ptr,"{%d} wl =0x%x, wt=0x%x, ww=0x%x, wh=0x%x, compressor_margin=0x%x\n",sensor_port, wl, wt, ww, wh, compressor_margin);
// flip margins for mirrored images (except oversized, not to rely on sensor->clearWidth/sensor->clearHeight
if (!thispars->pars[P_OVERSIZE]) {
if(flipX) {
......@@ -1052,6 +1056,7 @@ int mt9x001_pgm_window_common (int sensor_port, ///< sensor port
// apply clearTop/clearLeft
wt = (wt + sensor->clearTop) & 0xfffe;
wl = (wl + sensor->clearLeft) & 0xfffe;
dev_dbg(g_dev_ptr,"{%d} wl =0x%x, wt=0x%x\n",sensor_port, wl, wt);
// apply binning restrictions
switch(styp) {
case MT9P_TYP:
......
......@@ -942,7 +942,7 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
///< be applied to, negative - ASAP
///< @return always 0
{
int dv,dh,bv,bh,width,height,timestamp_len,oversize,pfh,pf_stripes,ah, left,top,is_color;
int dv,dh,bv,bh,width,height,timestamp_len,oversize,pfh,pf_stripes,ah, left,top,is_color,margins;
int sensor_width;
int sensor_height;
struct frameparspair_t pars_to_update[18]; // 15 needed, increase if more entries will be added
......@@ -956,11 +956,15 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
sensor_height=thispars->pars[P_SENSOR_HEIGHT];
oversize=thispars->pars[P_OVERSIZE];
is_color=1;
margins = 0;
switch (thispars->pars[P_COLOR] & 0x0f){
case COLORMODE_MONO6:
case COLORMODE_MONO4:
is_color=0;
break;
case COLORMODE_COLOR:
case COLORMODE_COLOR20:
margins = COLOR_MARGINS;
}
// flips changed?
if (FRAMEPAR_MODIFIED(P_FLIPH)) {
......@@ -1021,8 +1025,8 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
if (unlikely(thispars->pars[P_ACTUAL_WIDTH] != (width+timestamp_len))) {
SETFRAMEPARS_SET(P_ACTUAL_WIDTH, width+timestamp_len); ///full width for the compressor, including timestamp, but excluding margins
}
if (unlikely(thispars->pars[P_SENSOR_PIXH] != width+(2 * COLOR_MARGINS)))
SETFRAMEPARS_SET(P_SENSOR_PIXH, width+(2 * COLOR_MARGINS)); ///full width for the sensor (after decimation), including margins
if (unlikely(thispars->pars[P_SENSOR_PIXH] != width+(2 * margins)))
SETFRAMEPARS_SET(P_SENSOR_PIXH, width+(2 * margins)); ///full width for the sensor (after decimation), including margins
width*=dh;
if (unlikely(thispars->pars[P_WOI_WIDTH] != width))
SETFRAMEPARS_SET(P_WOI_WIDTH, width); // WOI width, as specified (corrected for the sensor if needed)
......@@ -1046,8 +1050,8 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
height= ((height/dv)/X393_TILEVERT) * X393_TILEVERT; // divided by dv (before multisensor options)
// suppose minimal height refers to decimated output
while (height < sensor->minHeight) height+=X393_TILEVERT;
if (unlikely(thispars->pars[P_SENSOR_PIXV] != height+(2 * COLOR_MARGINS)))
SETFRAMEPARS_SET(P_SENSOR_PIXV, height+(2 * COLOR_MARGINS)); ///full height for the sensor (after decimation), including margins
if (unlikely(thispars->pars[P_SENSOR_PIXV] != height+(2 * margins)))
SETFRAMEPARS_SET(P_SENSOR_PIXV, height+(2 * margins)); ///full height for the sensor (after decimation), including margins
height*=dv;
pf_stripes = 0;
pfh = 0;
......@@ -1075,8 +1079,8 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
left = thispars->pars[P_WOI_LEFT];
if (!oversize) { // in oversize mode let user to specify any margin, including odd ones (bayer shifted)
if (is_color) left &= 0xfffe;
if ((left + width + (2 * COLOR_MARGINS)) > sensor->clearWidth) {
left = sensor->clearWidth - width - (2 * COLOR_MARGINS);
if ((left + width + (2 * margins)) > sensor->clearWidth) {
left = sensor->clearWidth - width - (2 * margins);
if (is_color) left &= 0xfffe;
}
if (left & 0x8000) left = 0;
......@@ -1093,8 +1097,8 @@ int pgm_window_common (int sensor_port, ///< sensor port number (
clearHeight=(sensor->clearHeight-sensor->imageHeight) + thispars->pars[P_SENSOR_HEIGHT];
if (!oversize) { // in oversize mode let user to specify any margin, including odd ones (bayer shifted)
if (is_color) top &= 0xfffe;
if ((top + ((pfh>0)?0:height) + (2 * COLOR_MARGINS)) > clearHeight) {
top = clearHeight - ((pfh>0)?0:height) - (2 * COLOR_MARGINS);
if ((top + ((pfh>0)?0:height) + (2 * margins)) > clearHeight) {
top = clearHeight - ((pfh>0)?0:height) - (2 * margins);
if (is_color) top &= 0xfffe;
}
if (top & 0x8000) top = 0;
......@@ -1360,11 +1364,19 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
int n_scan_lines; //, n_ph_lines;
int flips;
int bayer_modified;
int margins;
x393_mcntrl_frame_start_dly_t start_dly ={.d32=0};
dev_dbg(g_dev_ptr,"{%d} frame16=%d\n",sensor_port,frame16);
MDP(DBGB_PSFN, sensor_port,"frame16=%d\n",frame16)
if (frame16 >= PARS_FRAMES) return -1; // wrong frame
margins = 0;
switch (thispars->pars[P_COLOR] & 0x0f){
case COLORMODE_COLOR:
case COLORMODE_COLOR20:
margins = COLOR_MARGINS;
}
if (FRAMEPAR_MODIFIED(P_BITS)){
sens_mode.bit16 = thispars->pars[P_BITS];
sens_mode.bit16_set = 1;
......@@ -1383,7 +1395,7 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
}
// Writing WOI width for internally generated HACT
if (thispars->pars[P_FRAMESYNC_DLY] & 0x10000) { /// set enforced HACT length, if 0 - use HACT from sensor
sensio_width.sensor_width = thispars->pars[P_ACTUAL_WIDTH]+(2 * COLOR_MARGINS);
sensio_width.sensor_width = thispars->pars[P_ACTUAL_WIDTH]+(2 * margins);
}
X393_SEQ_SEND1 (sensor_port, frame16, x393_sensio_width, sensio_width);
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sensio_width, 0x%x)\n",
......@@ -1398,7 +1410,7 @@ int pgm_sensorin (int sensor_port, ///< sensor port number (0..3
n_scan_lines= thispars->pars[P_ACTUAL_HEIGHT]; // no margins here
} else {
// temporary hack trying to disable PH mode earlier
n_scan_lines= thispars->pars[P_ACTUAL_HEIGHT]+(2 * COLOR_MARGINS)+thispars->pars[P_OVERLAP];
n_scan_lines= thispars->pars[P_ACTUAL_HEIGHT]+(2 * margins)+thispars->pars[P_OVERLAP];
}
X393_SEQ_SEND1 (sensor_port, frame16, x393_sens_sync_mult, sync_mult);
dev_dbg(g_dev_ptr,"{%d} X393_SEQ_SEND1(0x%x, 0x%x, x393_sens_sync_mult, 0x%x)\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment