Commit 601390c2 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

+ comment about buffer channels

parent 36c005e0
......@@ -3,7 +3,7 @@ from __future__ import print_function
'''
# Copyright (C) 2015, Elphel.inc.
# Class to control image acquisition and compression functionality
# Class to control image acquisition and compression functionality
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
......@@ -148,12 +148,12 @@ class X393SensCmprs(object):
x393Sensor = None
x393Rtc = None
x393Membridge = None
def __init__(self, debug_mode=1,dry_mode=True, saveFileName=None):
# global BUFFER_ADDRESS, BUFFER_LEN
global BUFFER_ADDRESS, BUFFER_LEN, COMMAND_ADDRESS, DATAIN_ADDRESS, DATAOUT_ADDRESS
global BUFFER_ADDRESS_H2D, BUFFER_LEN_H2D, BUFFER_ADDRESS_D2H, BUFFER_LEN_D2H, BUFFER_ADDRESS_BIDIR, BUFFER_LEN_BIDIR
# global SENSOR_DEFAULTS_SIMULATION
# global SENSOR_DEFAULTS_SIMULATION
print ("X393SensCmprs.__init__: dry_mode=",dry_mode)
if (dry_mode):
try:
......@@ -168,16 +168,16 @@ class X393SensCmprs(object):
SENSOR_DEFAULTS[x393_sensor.SENSOR_INTERFACE_HISPI]["top"]= 0
SENSOR_DEFAULTS[x393_sensor.SENSOR_INTERFACE_HISPI]["left"]= 0
print ("Using simulation size sensor defaults ",SENSOR_DEFAULTS)
except:
print ("No simulation server is used, just running in dry mode")
print ("No simulation server is used, just running in dry mode")
self.DEBUG_MODE= debug_mode
self.DRY_MODE= dry_mode
self.x393_mem= X393Mem(debug_mode,dry_mode)
self.x393_axi_tasks= x393_axi_control_status.X393AxiControlStatus(debug_mode,dry_mode)
self.x393_utils= x393_utils.X393Utils(debug_mode,dry_mode, saveFileName) # should not overwrite save file path
self.x393Camsync = x393_camsync.X393Camsync(debug_mode,dry_mode, saveFileName)
self.x393GPIO = x393_gpio.X393GPIO(debug_mode,dry_mode, saveFileName)
self.x393CmprsAfi = x393_cmprs_afi.X393CmprsAfi(debug_mode,dry_mode, saveFileName)
......@@ -211,8 +211,8 @@ class X393SensCmprs(object):
BUFFER_ADDRESS_BIDIR = 0x25500000
BUFFER_LEN_BIDIR = 0x19000000
print ("Running in simulated mode, using hard-coded addresses:")
else:
try:
......@@ -222,8 +222,8 @@ class X393SensCmprs(object):
BUFFER_LEN = PAGE_SIZE * int(sysfile.read(),0)
except:
print("Failed to get reserved physical memory range")
print('BUFFER_ADDRESS=', BUFFER_ADDRESS)
print('BUFFER_LEN=', BUFFER_LEN)
print('BUFFER_ADDRESS=', BUFFER_ADDRESS)
print('BUFFER_LEN=', BUFFER_LEN)
return
try:
......@@ -233,10 +233,10 @@ class X393SensCmprs(object):
BUFFER_LEN_H2D=PAGE_SIZE*int(sysfile.read(),0)
except:
print("Failed to get reserved physical memory range")
print('BUFFER_ADDRESS_H2D=',BUFFER_ADDRESS_H2D)
print('BUFFER_LEN_H2D=',BUFFER_LEN_H2D)
print('BUFFER_ADDRESS_H2D=',BUFFER_ADDRESS_H2D)
print('BUFFER_LEN_H2D=',BUFFER_LEN_H2D)
return
try:
with open(MEM_PATH + BUFFER_D2H_ADDRESS_NAME) as sysfile:
BUFFER_ADDRESS_D2H=int(sysfile.read(),0)
......@@ -244,10 +244,10 @@ class X393SensCmprs(object):
BUFFER_LEN_D2H=PAGE_SIZE*int(sysfile.read(),0)
except:
print("Failed to get reserved physical memory range")
print('BUFFER_ADDRESS_D2H=',BUFFER_ADDRESS_D2H)
print('BUFFER_LEN_D2H=',BUFFER_LEN_D2H)
print('BUFFER_ADDRESS_D2H=',BUFFER_ADDRESS_D2H)
print('BUFFER_LEN_D2H=',BUFFER_LEN_D2H)
return
try:
with open(MEM_PATH + BUFFER_BIDIR_ADDRESS_NAME) as sysfile:
BUFFER_ADDRESS_BIDIR=int(sysfile.read(),0)
......@@ -255,19 +255,19 @@ class X393SensCmprs(object):
BUFFER_LEN_BIDIR=PAGE_SIZE*int(sysfile.read(),0)
except:
print("Failed to get reserved physical memory range")
print('BUFFER_ADDRESS_BIDIR=',BUFFER_ADDRESS_BIDIR)
print('BUFFER_LEN_BIDIR=',BUFFER_LEN_BIDIR)
print('BUFFER_ADDRESS_BIDIR=',BUFFER_ADDRESS_BIDIR)
print('BUFFER_LEN_BIDIR=',BUFFER_LEN_BIDIR)
return
print('X393SensCmprs: BUFFER_ADDRESS=0x%x'%(BUFFER_ADDRESS))
print('X393SensCmprs: BUFFER_ADDRESS=0x%x'%(BUFFER_ADDRESS))
print('X393SensCmprs: BUFFER_LEN=0x%x'%(BUFFER_LEN))
def get_histogram_byte_start(self): # should be 4KB page aligned
global BUFFER_ADDRESS
return BUFFER_ADDRESS
def get_circbuf_byte_start(self): # should be 4KB page aligned
global BUFFER_ADDRESS
return BUFFER_ADDRESS + 4096* (1 << vrlg.NUM_FRAME_BITS)* 16 # 16 subchannels
return BUFFER_ADDRESS + 4096* (1 << vrlg.NUM_FRAME_BITS)* 16 # 16 subchannels
def get_circbuf_byte_end(self): # should be 4KB page aligned
global BUFFER_ADDRESS, BUFFER_LEN
return BUFFER_ADDRESS + BUFFER_LEN
......@@ -276,16 +276,16 @@ class X393SensCmprs(object):
Sleep for specified number of milliseconds
@param time_ms - sleep time in milliseconds
"""
if (time_ms):
if (time_ms):
time.sleep(0.001*time_ms)
def setSensorClock(self, freq_MHz = 24.0, iface = "2V5_LVDS", quiet = 0):
"""
Set up external clock for sensor-synchronous circuitry (and sensor(s) themselves.
Set up external clock for sensor-synchronous circuitry (and sensor(s) themselves.
Currently required clock frequency is 1/4 of the sensor clock, so it is 24MHz for 96MHz sensor
@param freq_MHz - input clock frequency (MHz). Currently for 96MHZ sensor clock it should be 24.0
@param iface - one of the supported interfaces
(see ls /sys/devices/soc0/amba@0/e0004000.ps7-i2c/i2c-0/0-0070/output_drivers)
@param quiet - reduce output
@param quiet - reduce output
"""
if self.DRY_MODE:
print ("Not defined for simulation mode")
......@@ -295,38 +295,38 @@ class X393SensCmprs(object):
with open ( SI5338_PATH + "/output_clocks/out2_freq_fract","w") as f:
print("%d"%(round(1000000*freq_MHz)), file = f )
if quiet == 0:
print ("Set sensor clock to %f MHz, driver type \"%s\""%(freq_MHz,iface))
print ("Set sensor clock to %f MHz, driver type \"%s\""%(freq_MHz,iface))
def setSensorPower(self, sub_pair=0, power_on=0, quiet=0):
"""
@param sub_pair - pair of the sensors: 0 - sensors 1 and 2, 1 - sensors 3 and 4
@param power_on - 1 - power on, 0 - power off (both sensor power and interface/FPGA bank voltage)
@param quiet - reduce output
@param sub_pair - pair of the sensors: 0 - sensors 1 and 2, 1 - sensors 3 and 4
@param power_on - 1 - power on, 0 - power off (both sensor power and interface/FPGA bank voltage)
@param quiet - reduce output
"""
if quiet == 0:
print (("vcc_sens01 vp33sens01", "vcc_sens23 vp33sens23")[sub_pair]+" -> "+POWER393_PATH + "/channels_"+ ("dis","en")[power_on])
print (("vcc_sens01 vp33sens01", "vcc_sens23 vp33sens23")[sub_pair]+" -> "+POWER393_PATH + "/channels_"+ ("dis","en")[power_on])
with open (POWER393_PATH + "/channels_"+ ("dis","en")[power_on],"w") as f:
print(("vcc_sens01 vp33sens01", "vcc_sens23 vp33sens23")[sub_pair], file = f)
def setSensorIfaceVoltage(self, sub_pair, voltage_mv, quiet = 0):
"""
Set interface voltage (should be done before power is on)
@param sub_pair - pair of the sensors: 0 - sensors 1 and 2, 1 - sensors 3 and 4
@param voltage_mv - desired interface voltage (1800..2800 mv)
@param quiet - reduce output
Set interface voltage (should be done before power is on)
@param sub_pair - pair of the sensors: 0 - sensors 1 and 2, 1 - sensors 3 and 4
@param voltage_mv - desired interface voltage (1800..2800 mv)
@param quiet - reduce output
"""
with open (POWER393_PATH + "/voltages_mv/"+ ("vcc_sens01", "vcc_sens23")[sub_pair],"w") as f:
print(voltage_mv, file = f)
if quiet == 0:
print ("Set sensors %s interface voltage to %d mV"%(("0, 1","2, 3")[sub_pair],voltage_mv))
print ("Set sensors %s interface voltage to %d mV"%(("0, 1","2, 3")[sub_pair],voltage_mv))
time.sleep(0.1)
def setEyesisPower (self, en, dly_ms=0):
"""
Turn on/off external power supply for Eyesis sensor ports. At startup stupid GPIO system
interface "thinks" it is off, but it is actually on. So to turn off after boot On-Off sequence
is needed
@param en True or 1 - turn power on, False or 0 - turn off
@param dly_ms - delay in ms after turning power on or off
@param dly_ms - delay in ms after turning power on or off
"""
if self.DRY_MODE:
print ("setEyesisPower() is not defined for simulation mode")
......@@ -347,8 +347,8 @@ class X393SensCmprs(object):
if self.DRY_MODE:
print ("setupEyesisPower() is not defined for simulation mode")
return
#turn off external sensor power
self.setEyesisPower (True, 0) # stupid GPIO after reset will not turn off if it thinks it is off
#turn off external sensor power
self.setEyesisPower (True, 0) # stupid GPIO after reset will not turn off if it thinks it is off
self.setEyesisPower (False, dly2_ms)
#Turn off on-board sensor power (just in case)
for sub_pair in (0,1):
......@@ -365,10 +365,10 @@ class X393SensCmprs(object):
"""
Set interface voltage and turn on power for interface and the sensors
according to sensor type
@param ifaceType "PAR12" or "HISPI"
@param pairs - 'all' or list/tuple of pairs of the sensors: 0 - sensors 1 and 2, 1 - sensors 3 and 4
@param quiet - reduce output
@param dly - debug feature: step delay in sec
@param ifaceType "PAR12" or "HISPI"
@param pairs - 'all' or list/tuple of pairs of the sensors: 0 - sensors 1 and 2, 1 - sensors 3 and 4
@param quiet - reduce output
@param dly - debug feature: step delay in sec
"""
try:
if (pairs == all) or (pairs[0].upper() == "A"): #all is a built-in function
......@@ -377,19 +377,19 @@ class X393SensCmprs(object):
pass
if not isinstance(pairs,(list,tuple)):
pairs = (pairs,)
for pair in pairs:
for pair in pairs:
self.setSensorIfaceVoltagePower(sub_pair = pair,
voltage_mv = SENSOR_INTERFACES[ifaceType]["mv"],
quiet = quiet,
dly = dly)
def setSensorIfaceVoltagePower(self, sub_pair, voltage_mv, quiet=0, dly=0.0):
"""
Set interface voltage and turn on power for interface and the sensors
@param sub_pair - pair of the sensors: 0 - sensors 1 and 2, 1 - sensors 3 and 4
@param voltage_mv - desired interface voltage (1800..2800 mv)
@param quiet - reduce output
@param dly - debug feature: step delay in sec
Set interface voltage and turn on power for interface and the sensors
@param sub_pair - pair of the sensors: 0 - sensors 1 and 2, 1 - sensors 3 and 4
@param voltage_mv - desired interface voltage (1800..2800 mv)
@param quiet - reduce output
@param dly - debug feature: step delay in sec
"""
self.setSensorPower(sub_pair = sub_pair, power_on = 0)
time.sleep(2*dly)
......@@ -399,17 +399,17 @@ class X393SensCmprs(object):
print ("Not defined for simulation mode")
return
if quiet == 0:
print ("Turning on interface power %f V for sensors %s"%(voltage_mv*0.001,("0, 1","2, 3")[sub_pair]))
print ("Turning on interface power %f V for sensors %s"%(voltage_mv*0.001,("0, 1","2, 3")[sub_pair]))
time.sleep(3*dly)
with open (POWER393_PATH + "/channels_en","w") as f:
print(("vcc_sens01", "vcc_sens23")[sub_pair], file = f)
if quiet == 0:
print ("Turned on interface power %f V for sensors %s"%(voltage_mv*0.001,("0, 1","2, 3")[sub_pair]))
print ("Turned on interface power %f V for sensors %s"%(voltage_mv*0.001,("0, 1","2, 3")[sub_pair]))
time.sleep(3*dly)
with open (POWER393_PATH + "/channels_en","w") as f:
print(("vp33sens01", "vp33sens23")[sub_pair], file = f)
if quiet == 0:
print ("Turned on +3.3V power for sensors %s"%(("0, 1","2, 3")[sub_pair]))
print ("Turned on +3.3V power for sensors %s"%(("0, 1","2, 3")[sub_pair]))
time.sleep(2*dly)
......@@ -422,11 +422,11 @@ class X393SensCmprs(object):
ifaceType = self.x393Sensor.getSensorInterfaceType();
if setPower:
if quiet == 0:
print ("Configuring sensor ports for interface type: \"%s\""%(ifaceType))
print ("Configuring sensor ports for interface type: \"%s\""%(ifaceType))
for sub_pair in (0,1):
self.setSensorIfaceVoltagePower(sub_pair, SENSOR_INTERFACES[ifaceType]["mv"])
self.setSensorClock(freq_MHz = SENSOR_INTERFACES[ifaceType]["freq"], iface = SENSOR_INTERFACES[ifaceType]["iface"])
self.setSensorClock(freq_MHz = SENSOR_INTERFACES[ifaceType]["freq"], iface = SENSOR_INTERFACES[ifaceType]["iface"])
# def setSensorClock(self, freq_MHz = 24.0, iface = "2V5_LVDS"):
def setup_sensor_channel (self,
......@@ -438,7 +438,7 @@ class X393SensCmprs(object):
window_height = None, # 1944, # 1944
window_left = None, # 0, # 0
window_top = None, # 0, # 0? 1?
# compressor_left_margin = 0, #0?`1?
# compressor_left_margin = 0, #0?`1?
# frame_start_address, # calculate through num_sensor, num frames, frame size and start addr?
# frame_start_address_inc,
last_buf_frame = 1, # - just 2-frame buffer
......@@ -492,7 +492,7 @@ class X393SensCmprs(object):
@param histogram_top - histogram window top margin
@param histogram_width_m1 - one less than window width. If 0 - use frame right margin (end of HACT)
@param histogram_height_m1 - one less than window height. If 0 - use frame bottom margin (end of VACT)
???
@param verbose - verbose level
@return True if all done, False if exited prematurely through exit_step
......@@ -523,9 +523,9 @@ class X393SensCmprs(object):
if window_top is None:
window_top = SENSOR_DEFAULTS[sensorType]["top"]
"""
#setting up histogram window, same for parallel, similar for serial
if histogram_left is None:
histogram_left = 0
if histogram_top is None:
......@@ -535,13 +535,13 @@ class X393SensCmprs(object):
if histogram_height_m1 is None:
histogram_height_m1 = window_height - 9
align_to_bursts = 64 # align full width to multiple of align_to_bursts. 64 is the size of memory access
width_in_bursts = window_width >> 4
if (window_width & 0xf):
width_in_bursts += 1
compressor_left_margin = window_left % 32
num_burst_in_line = (window_left >> 4) + width_in_bursts
num_pages_in_line = num_burst_in_line // align_to_bursts;
if num_burst_in_line % align_to_bursts:
......@@ -552,21 +552,21 @@ class X393SensCmprs(object):
"""
Changing frame full width and size to fixed values (normally read from sysfs)
frame_full_width = num_pages_in_line * align_to_bursts
"""
frame_full_width = 0x200 # Made it fixed width
num8rows= (window_top + window_height) // 8
if (window_top + window_height) % 8:
num8rows += 1
"""
"""
frame_start_address_inc = num8rows * frame_full_width
"""
frame_start_address_inc = 0x80000 #Fixed size
""" TODO: Calculate tiles and move to initial print """
num_macro_cols_m1 = (window_width >> 4) - 1
num_macro_rows_m1 = (window_height >> 4) - 1
......@@ -577,7 +577,7 @@ class X393SensCmprs(object):
# histogram_start_phys_page - system memory 4K page number to start histogram
histogram_start_phys_page = self.get_histogram_byte_start() // 4096
if verbose >0 :
print ("setup_sensor_channel:")
print ("num_sensor = ", num_sensor)
......@@ -600,7 +600,7 @@ class X393SensCmprs(object):
print ("cmode = ", cmode)
print ("verbose = ", verbose)
if exit_step == 10: return False
self.x393Sensor.program_status_sensor_i2c(
num_sensor = num_sensor, # input [1:0] num_sensor;
mode = 3, # input [1:0] mode;
......@@ -616,15 +616,15 @@ class X393SensCmprs(object):
seq_num = 0); # input [5:0] seq_num;
if exit_step == 11: return False
# moved before camsync to have a valid timestamo w/o special waiting
# moved before camsync to have a valid timestamo w/o special waiting
if verbose >0 :
print ("===================== MEMORY_SENSOR =========================")
window_height_memory = window_height
if cmode==vrlg.CMPRS_CBIT_CMODE_JP4:
window_height_memory &= 0xfff0 # do not need extra margins
num_burst_in_line &= 0xfffe # make even (assuming left=0)
num_burst_in_line &= 0xfffe # make even (assuming left=0)
self.x393Sensor.setup_sensor_memory (
num_sensor = num_sensor, # input [1:0] num_sensor;
frame_sa = frame_start_address, # input [31:0] frame_sa; # 22-bit frame start address ((3 CA LSBs==0. BA==0)
......@@ -647,7 +647,7 @@ class X393SensCmprs(object):
run_mode = 0) # reset compressor
#TODO: Calculate from the image size?
"""
#How it was
#How it was
self.x393Cmprs.setup_compressor_channel (
chn = num_sensor,
qbank = 0,
......@@ -671,7 +671,7 @@ class X393SensCmprs(object):
# last_tile32 = (window_left + (window_width & ~0xf) + tile_margin - 1) // 32
last_tile32 = (window_left + ((num_macro_cols_m1 + 1) * 16) + tile_margin - 1) // 32
width32 = last_tile32 - left_tiles32 + 1 # number of 32-wide tiles needed in each row
if (verbose > 0) :
print ("setup_compressor_memory:")
print ("num_sensor = ", num_sensor)
......@@ -729,17 +729,17 @@ class X393SensCmprs(object):
if exit_step == 15: return False
self.x393Cmprs.compressor_control(
chn = num_sensor,
run_mode = 0) # 3) # run repetitive mode
if exit_step == 16: return False
#Set up delays separately, outside of this method
"""
"""
if verbose >0 :
print ("===================== DELAYS_SETUP =========================")
self.x393Sensor.set_sensor_io_dly (
num_sensor = num_sensor,
mmcm_phase = 0,
......@@ -749,8 +749,8 @@ class X393SensCmprs(object):
pxd_dly = 0)
self.x393Sensor.set_sensor_io_ctl (
quadrants = vrlg.QUADRANTS_PXD_HACT_VACT)
"""
"""
if verbose >0 :
print ("===================== IO_SETUP =========================")
self.x393Sensor.set_sensor_io_width(
......@@ -761,7 +761,7 @@ class X393SensCmprs(object):
mrst = False,
arst = False,
aro = False,
mmcm_rst = True, #reset mmcm
mmcm_rst = True, #reset mmcm
clk_sel = None, #Dealing with Unisims bug: "Error: [Unisim MMCME2_ADV-4] Input clock can only be switched when..."
set_delays = False,
quadrants = None)
......@@ -771,7 +771,7 @@ class X393SensCmprs(object):
mrst = False,
arst = False,
aro = False,
mmcm_rst = True, #reset mmcm
mmcm_rst = True, #reset mmcm
clk_sel = clk_sel,
set_delays = False,
quadrants = None)
......@@ -815,12 +815,12 @@ class X393SensCmprs(object):
if verbose >0 :
print ("===================== GAMMA_SETUP =========================")
self.x393Sensor.set_sensor_gamma_heights (
self.x393Sensor.set_sensor_gamma_heights (
num_sensor = num_sensor,
height0_m1 = 0xffff,
height1_m1 = 0,
height2_m1 = 0)
# Configure histograms
if verbose >0 :
print ("===================== HISTOGRAMS_SETUP =========================")
......@@ -836,7 +836,7 @@ class X393SensCmprs(object):
num_sensor = num_sensor,
subchannel = 0,
page = histogram_start_phys_page) # for the channel/subchannel = 0/0
self.x393Sensor.set_sensor_histogram_saxi (
en = True,
nrst = True,
......@@ -848,12 +848,12 @@ class X393SensCmprs(object):
# Run after histogram channel is set up?
if verbose >0 :
print ("===================== SENSOR_SETUP =========================")
self.x393Sensor.set_sensor_mode (
num_sensor = num_sensor,
hist_en = 1, # bitmask, only first subchannel
hist_nrst = 1, # bitmask, only first subchannel
chn_en = True,
hist_nrst = 1, # bitmask, only first subchannel
chn_en = True,
bits16 = False)
if verbose >0 :
......@@ -885,12 +885,12 @@ class X393SensCmprs(object):
c_quality = None, # use "same" to save None
portrait = None,
gamma = None,
black = None, # 0.04
black = None, # 0.04
colorsat_blue = None, # colorsat_blue, #0x120 # 0x90 for 1x
colorsat_red = None, # colorsat_red, #0x16c, # 0xb6 for x1
verbose = 1
):
global GLBL_WINDOW
if GLBL_WINDOW is None:
GLBL_WINDOW = {}
......@@ -941,14 +941,14 @@ class X393SensCmprs(object):
except:
c_quality = "same"
if c_quality == "same": # to save as None, not to not save
c_quality = None
c_quality = None
if portrait is None:
try:
portrait = GLBL_WINDOW["portrait"]
except:
portrait = False
if gamma is None:
try:
gamma = GLBL_WINDOW["gamma"]
......@@ -972,7 +972,7 @@ class X393SensCmprs(object):
colorsat_red = GLBL_WINDOW["colorsat_red"]
except:
colorsat_red = 2.0 # *0xb6
GLBL_WINDOW = {"width": window_width,
"height": window_height,
"left": window_left,
......@@ -992,8 +992,8 @@ class X393SensCmprs(object):
for k in GLBL_WINDOW.keys():
print ("%15s:%s"%(k,str(GLBL_WINDOW[k])))
return GLBL_WINDOW
def specify_phys_memory(self,
circbuf_chn_size= 0x4000000,
verbose = 1):
......@@ -1003,7 +1003,7 @@ class X393SensCmprs(object):
global GLBL_CIRCBUF_CHN_SIZE, GLBL_CIRCBUF_STARTS, GLBL_CIRCBUF_ENDS, GLBL_CIRCBUF_END, GLBL_MEMBRIDGE_START, GLBL_MEMBRIDGE_END, GLBL_BUFFER_END
global GLBL_MEMBRIDGE_H2D_START, GLBL_MEMBRIDGE_H2D_END, GLBL_MEMBRIDGE_D2H_START, GLBL_MEMBRIDGE_D2H_END
global BUFFER_ADDRESS_H2D, BUFFER_LEN_H2D, BUFFER_ADDRESS_D2H, BUFFER_LEN_D2H
circbuf_start = self.get_circbuf_byte_start()
GLBL_BUFFER_END= self.get_circbuf_byte_end()
GLBL_CIRCBUF_CHN_SIZE = circbuf_chn_size
......@@ -1021,7 +1021,7 @@ class X393SensCmprs(object):
GLBL_MEMBRIDGE_D2H_START = BUFFER_ADDRESS_D2H
GLBL_MEMBRIDGE_D2H_END = BUFFER_ADDRESS_D2H + BUFFER_LEN_D2H
if verbose >0 :
print ("compressor system memory buffers:")
print ("circbuf start 0 = 0x%x"%(GLBL_CIRCBUF_STARTS[0]))
......@@ -1044,7 +1044,7 @@ class X393SensCmprs(object):
"""
Configure status report for command sequencer to report 4 LSB of each channel frame number
with get_frame_numbers()
"""
"""
self.x393_axi_tasks.program_status( # also takes snapshot
base_addr = vrlg.CMDSEQMUX_ADDR,
reg_addr = 0,
......@@ -1066,7 +1066,7 @@ class X393SensCmprs(object):
"""
status = self.x393_axi_tasks.read_status(address = vrlg.CMDSEQMUX_STATUS)
return int((status >> (4*channel)) & 0xf)
def get_frame_number_i2c(self,
channel=0):
"""
......@@ -1077,13 +1077,13 @@ class X393SensCmprs(object):
frames=[]
for channel in range(4):
frames.append(self.get_frame_number_i2c(channel = channel))
return frames
return frames
except:
pass
pass
status = self.x393_axi_tasks.read_status(
address = vrlg.SENSI2C_STATUS_REG_BASE + channel * vrlg.SENSI2C_STATUS_REG_INC + vrlg.SENSI2C_STATUS_REG_REL)
return int((status >> 12) & 0xf)
def skip_frame(self,
channel_mask,
loop_delay = 0.01,
......@@ -1103,7 +1103,7 @@ class X393SensCmprs(object):
frameno = new_frames[chn]
if all_new:
break;
return frameno # Frame number of the last new frame checked
return frameno # Frame number of the last new frame checked
def wait_frame(self,
channel = 0,
......@@ -1116,7 +1116,7 @@ class X393SensCmprs(object):
frameno = self.get_frame_number(channel)
if frameno == (frame & 15):
return frameno
return frameno # Frame number of the last new frame checked
return frameno # Frame number of the last new frame checked
def skip_frame_i2c(self,
channel_mask,
......@@ -1137,8 +1137,8 @@ class X393SensCmprs(object):
frameno = new_frames[chn]
if all_new:
break;
return frameno # Frame number of the last new frame checked
return frameno # Frame number of the last new frame checked
def setup_compressor(self,
chn,
cmode = 0, # vrlg.CMPRS_CBIT_CMODE_JPEG18,
......@@ -1176,7 +1176,7 @@ class X393SensCmprs(object):
@param dc_sub - True - subtract DC before running DCT, False - no subtraction, convert as is,
@param multi_frame - False - single-frame buffer, True - multi-frame video memory buffer,
@param bayer - Bayer shift (0..3)
@param focus_mode - focus mode - how to combine image with "focus quality" in the result image
@param focus_mode - focus mode - how to combine image with "focus quality" in the result image
@param coring - coring value
@param window_width - (here - in pixels)
@param window_height - 16-bit window height in scan lines
......@@ -1223,7 +1223,7 @@ class X393SensCmprs(object):
cmode = window["cmode"]
COLOR_MARGINS = 2
num_sensor = chn # 1:1 sensor - compressor
align_to_bursts = 64 # align full width to multiple of align_to_bursts. 64 is the size of memory access
"""
overlap = 0 # tile overlap (total - 2 for JPEG18, 4 - for JPEG20, 0 otherwise
......@@ -1233,7 +1233,7 @@ class X393SensCmprs(object):
cmprs_top = 1
elif cmode == vrlg.CMPRS_CBIT_CMODE_JPEG20:
overlap = 4
if overlap:
window_width += (2 * COLOR_MARGINS)
window_height += (2 * COLOR_MARGINS)
......@@ -1241,7 +1241,7 @@ class X393SensCmprs(object):
else:
tile_width = 4
# cmprs_frame_format.left_margin = cmprs_top; // same as top - only for 18x18 tiles to keep Bayer shift (0/1)
width_bursts = window_width >> 4
if window_width & 0xf:
width_bursts += 1
......@@ -1250,16 +1250,16 @@ class X393SensCmprs(object):
width_bursts += 1
if (tile_width > 2) and (width_bursts & 2):
width_bursts += 2
tile_height = 16 + overlap;
"""
width_in_bursts = window_width >> 4
if (window_width & 0xf):
width_in_bursts += 1
compressor_left_margin = window_left % 32
num_burst_in_line = (window_left >> 4) + width_in_bursts
num_pages_in_line = num_burst_in_line // align_to_bursts;
if num_burst_in_line % align_to_bursts:
......@@ -1267,14 +1267,14 @@ class X393SensCmprs(object):
"""
Changing frame full width and size to fixed values (normally read from sysfs)
frame_full_width = num_pages_in_line * align_to_bursts
"""
frame_full_width = 0x200 # Made it fixed width
num8rows= (window_top + window_height) // 8
if (window_top + window_height) % 8:
num8rows += 1
"""
"""
frame_start_address_inc = num8rows * frame_full_width
"""
frame_start_address_inc = 0x80000 #Fixed size
......@@ -1282,7 +1282,7 @@ class X393SensCmprs(object):
num_macro_cols_m1 = (window_width >> 4) - 1
num_macro_rows_m1 = (window_height >> 4) - 1
frame_start_address = (last_buf_frame + 1) * frame_start_address_inc * num_sensor
self.x393Cmprs.setup_compressor_channel (
chn = chn,
qbank = qbank,
......@@ -1303,7 +1303,7 @@ class X393SensCmprs(object):
tile_margin = 2 # 18x18 instead of 16x16
tile_width = 2
extra_pages = 1
else: # actually other modes should be parsed here, now considering just JP4 flavors
tile_margin = 0 # 18x18 instead of 16x16
tile_width = 4
......@@ -1315,7 +1315,7 @@ class X393SensCmprs(object):
left_tiles32 = window_left // 32
last_tile32 = (window_left + ((num_macro_cols_m1 + 1) * 16) + tile_margin - 1) // 32
width32 = last_tile32 - left_tiles32 + 1 # number of 32-wide tiles needed in each row
if (verbose > 0) :
print ("setup_compressor_memory:")
print ("num_sensor = ", num_sensor)
......@@ -1368,22 +1368,22 @@ class X393SensCmprs(object):
MASK_COMPRESSOR = 2
MASK_MEMSENSOR = 4
MASK_MEMCOMPRESSOR = 8
for chn in range (4):
if sensor_mask & (1 << chn):
if reset_mask & MASK_COMPRESSOR:
self.x393Cmprs.compressor_control (chn = chn,
run_mode = 1) # stop after frame done
if reset_mask & MASK_MEMSENSOR:
self.x393Sensor.control_sensor_memory (num_sensor = chn,
command = 'stop')
if reset_mask & MASK_MEMCOMPRESSOR:
self.x393Cmprs.control_compressor_memory (num_sensor = chn,
command = 'stop')
self.sleep_ms(200)
self.sleep_ms(200)
for chn in range (4):
if sensor_mask & (1 << chn):
if reset_mask & MASK_COMPRESSOR:
......@@ -1392,7 +1392,7 @@ class X393SensCmprs(object):
if reset_mask & MASK_MEMSENSOR:
self.x393Sensor.control_sensor_memory (num_sensor = chn,
command = 'reset')
if reset_mask & MASK_MEMCOMPRESSOR:
self.x393Cmprs.control_compressor_memory (num_sensor = chn,
command = 'reset')
......@@ -1401,7 +1401,7 @@ class X393SensCmprs(object):
self.x393Sensor.set_sensor_io_ctl (num_sensor = chn,
mrst = True)
def setup_all_sensors (self,