Commit a40eed25 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

more porting pgm_functions and related files

parent 7a3e1480
Loading
Loading
Loading
Loading
+31 −0
Original line number Original line Diff line number Diff line
@@ -117,6 +117,7 @@
#include <elphel/exifa.h>
#include <elphel/exifa.h>
//#include "fpgactrl.h"  // defines port_csp0_addr, port_csp4_addr
//#include "fpgactrl.h"  // defines port_csp0_addr, port_csp4_addr
#include "framepars.h"        // for debug mask
#include "framepars.h"        // for debug mask
#include "sensor_common.h"  // for FPGA_TABLE_CHUNK - or move it?


//#include "fpga_io.h"//fpga_table_write_nice
//#include "fpga_io.h"//fpga_table_write_nice


@@ -126,6 +127,7 @@
//#include "framepars.h"
//#include "framepars.h"
//#include "quantization_tables.h"
//#include "quantization_tables.h"
#include "gamma_tables.h"
#include "gamma_tables.h"
#include "x393.h"
/**
/**
 * @brief optional debug output 
 * @brief optional debug output 
 */
 */
@@ -666,6 +668,35 @@ int set_gamma_table (unsigned short hash16, ///< 16-bit unique (non-scale
  return tmp_p1;
  return tmp_p1;
}
}


/** Writing gamma table to FPGA (1 color, 1 sub-channel) enabling IRQ after transferring each FPGA_TABLE_CHUNK DWORDs */
void fpga_gamma_write_nice(int color,         ///< Color (0..3)
                           int sensor_port,   ///< sensor port (0..3)
                           int sensor_subchn, ///< sensor sub-channel (when several are connected through a multiplexer)
                           u32 * gamma)       ///< Gamma table (256 DWORDs) in encoded FPGA format
{
    x393_gamma_tbl_t gamma_tbl_a = {.d32=0};
    x393_gamma_tbl_t gamma_tbl_d = {.d32=0};
    const int gamma_size=256; // 18-bit entries
    unsigned long flags;
    int addr32, len32, i;

    gamma_tbl_a.a_n_d = 1;
    gamma_tbl_a.color = color;
    gamma_tbl_a.sub_chn = sensor_subchn;
    for (addr32 = 0; addr32 < gamma_size; addr32 += FPGA_TABLE_CHUNK){
        len32 = FPGA_TABLE_CHUNK;
        if (unlikely(addr32 + len32 > gamma_size))
            len32 = gamma_size - addr32;
        gamma_tbl_a.addr= addr32;
        local_irq_save(flags);
        x393_sens_gamma_tbl(gamma_tbl_a, sensor_port);
        for (i = addr32; i < addr32 + len32; i++){
            gamma_tbl_d.d32 = gamma[i];
            x393_sens_gamma_tbl(gamma_tbl_d, sensor_port);
        }
        local_irq_restore(flags);
    }
}


///======================================
///======================================
// File operations:
// File operations:
+2 −0
Original line number Original line Diff line number Diff line
@@ -12,6 +12,8 @@ int unlock_gamma_node (int color, int sensor_port, int sensor_subchn); /// NOTE:
/// return a pointer to the gamma table (single color) encoded in FPGA format (NULL if there is to table ready)
/// return a pointer to the gamma table (single color) encoded in FPGA format (NULL if there is to table ready)
///
///
unsigned long * get_gamma_fpga(int color, int sensor_port, int sensor_subchn);
unsigned long * get_gamma_fpga(int color, int sensor_port, int sensor_subchn);
void fpga_gamma_write_nice    (int color, int sensor_port, int sensor_subchn, u32 * gamma);



int gamma_new_node(void);
int gamma_new_node(void);
void gamma_encode_fpga(unsigned short * gamma_in, unsigned long * gamma_out);///Hardware-dependent encoding of the FPGA "gamma" table. Converts unsigned short array of 257 16-bit values (only 10 msb-s are used) to 256 unsigned long words to be written to FPGA
void gamma_encode_fpga(unsigned short * gamma_in, unsigned long * gamma_out);///Hardware-dependent encoding of the FPGA "gamma" table. Converts unsigned short array of 257 16-bit values (only 10 msb-s are used) to 256 unsigned long words to be written to FPGA
+358 −154

File changed.

Preview size limit exceeded, changes collapsed.

+8 −8
Original line number Original line Diff line number Diff line
@@ -993,14 +993,13 @@ static unsigned long coring_tables[] = {
/**
/**
 * @brief Directly set one of the coring LUTs (currently 100: 0.0 to 9.9 with 0.1 step)
 * @brief Directly set one of the coring LUTs (currently 100: 0.0 to 9.9 with 0.1 step)
 *        to one of 16 FPGA tables (even - for Y, odd - for C)
 *        to one of 16 FPGA tables (even - for Y, odd - for C)
 * @param[in]   coring_number   0..99 - function number
 * Table is rather small, so turn off IRQ  for the whole duration */
 * @param[in]   fpga_tbl_num    0..15 - FPGA table number
void set_coring_fpga(unsigned int coring_number, ///< [in]   0..99 - function number
 * @param[in]   chn             compressor channel number
                     int fpga_tbl_num,           ///< [in]   0..15 - FPGA table number
 * @return None
                     unsigned int chn)           ///< [in]   compressor channel number
 */
void set_coring_fpga(unsigned int coring_number, int fpga_tbl_num, unsigned int chn)
{
{
	int i;
	int i;
    unsigned long flags;
	x393_cmprs_table_addr_t table_addr;
	x393_cmprs_table_addr_t table_addr;


	if (coring_number >= sizeof(coring_tables) / (4 * CORING_SIZE))
	if (coring_number >= sizeof(coring_tables) / (4 * CORING_SIZE))
@@ -1010,11 +1009,12 @@ void set_coring_fpga(unsigned int coring_number, int fpga_tbl_num, unsigned int


	table_addr.type = TABLE_TYPE_CORING;
	table_addr.type = TABLE_TYPE_CORING;
	table_addr.addr32 = fpga_tbl_num * CORING_SIZE;
	table_addr.addr32 = fpga_tbl_num * CORING_SIZE;
    local_irq_save(flags);
	x393_cmprs_tables_address(table_addr, chn);
	x393_cmprs_tables_address(table_addr, chn);
	for (i = 0; i < CORING_SIZE; i++) {
	for (i = 0; i < CORING_SIZE; i++) {
		x393_cmprs_tables_data(coring_tables[coring_number * CORING_SIZE], chn);
		x393_cmprs_tables_data(coring_tables[coring_number * CORING_SIZE + i], chn);
	}
	}

    local_irq_restore(flags);
	print_hex_dump_bytes("", DUMP_PREFIX_NONE, &coring_tables[coring_number * CORING_SIZE], CORING_SIZE * 4);
	print_hex_dump_bytes("", DUMP_PREFIX_NONE, &coring_tables[coring_number * CORING_SIZE], CORING_SIZE * 4);
}
}


+0 −3
Original line number Original line Diff line number Diff line
@@ -17,7 +17,4 @@
#include "x393.h"
#include "x393.h"
#include "x393_fpga_functions.h"
#include "x393_fpga_functions.h"


/*

 */
Loading