Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
libisp.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include "libisp.h"
+ Include dependency graph for libisp.c:

Go to the source code of this file.

Data Structures

struct  avi_isp_offsets
 

Macros

#define AVI_BASE   0x400000
 
#define AVI_SIZE   0x100000
 
#define AVI_MASK   (AVI_SIZE - 1)
 
#define AVI_ISP_IOGET_OFFSETS   _IOR('F', 0x33, struct avi_isp_offsets)
 
#define readl(_addr)   (*((volatile uint32_t *)(_addr)))
 
#define writel(_val, _addr)   (*((volatile uint32_t *)(_addr)) = _val)
 
#define COMPLEMENT_2(i, r)   (((i) >= 0) ? (r) : (~(r) + 1) & 0x3fff)
 
#define Q311(i)   (COMPLEMENT_2(i, (unsigned)(((ABS(i)) * (1 << 11)) + 0.5)))
 
#define AVI_CONV_MATRIX(_c00, _c01, _c02,_c10, _c11, _c12,_c20, _c21, _c22)
 
#define AVI_CONV_OFFSETS(_ryin, _ryout,_guin, _guout,_bvin, _bvout)
 
#define AVI_CONV_CLIPS(_rymin, _rymax,_gumin, _gumax,_bvmin, _bvmax)
 
#define EXPAND_AS_FUNCTION(_node)
 

Functions

static int avi_isp_get_offsets_fd (int fd, struct avi_isp_offsets *off)
 This is taken from libisp. More...
 
static int open_isp_fd (struct libisp_context *ctx, int fd)
 This is taken from libisp. More...
 
static int close_isp (struct libisp_context *ctx)
 
int configure_isp (struct v4l2_device *dev)
 
static void memcpy_to_registers (unsigned long addr, const void *reg_base, size_t s)
 
static void memcpy_from_registers (void *reg_base, unsigned long addr, size_t s)
 

Variables

static const unsigned isp_bases []
 

Data Structure Documentation

struct avi_isp_offsets

Definition at line 17 of file libisp.c.

Data Fields
uint32_t chain_bayer
uint32_t chain_yuv
uint32_t chroma
uint32_t gamma_corrector
uint32_t statistics_yuv

Macro Definition Documentation

#define AVI_BASE   0x400000

Definition at line 13 of file libisp.c.

Referenced by open_isp_fd().

#define AVI_CONV_CLIPS (   _rymin,
  _rymax,
  _gumin,
  _gumax,
  _bvmin,
  _bvmax 
)
Value:
.clip_ry = {{ .clip_min = _rymin, .clip_max = _rymax }}, \
.clip_gu = {{ .clip_min = _gumin, .clip_max = _gumax }}, \
.clip_bv = {{ .clip_min = _bvmin, .clip_max = _bvmax }}

Referenced by configure_isp().

#define AVI_CONV_MATRIX (   _c00,
  _c01,
  _c02,
  _c10,
  _c11,
  _c12,
  _c20,
  _c21,
  _c22 
)
Value:
.coeff_01_00 = {{ .coeff_00 = Q311(_c00), .coeff_01 = Q311(_c01) }}, \
.coeff_10_02 = {{ .coeff_02 = Q311(_c02), .coeff_10 = Q311(_c10) }}, \
.coeff_12_11 = {{ .coeff_11 = Q311(_c11), .coeff_12 = Q311(_c12) }}, \
.coeff_21_20 = {{ .coeff_20 = Q311(_c20), .coeff_21 = Q311(_c21) }}, \
.coeff_22 = {{ .coeff_22 = Q311(_c22) }}
#define Q311(i)

Referenced by configure_isp().

#define AVI_CONV_OFFSETS (   _ryin,
  _ryout,
  _guin,
  _guout,
  _bvin,
  _bvout 
)
Value:
.offset_ry = {{ .offset_in = _ryin, .offset_out = _ryout }}, \
.offset_gu = {{ .offset_in = _guin, .offset_out = _guout }}, \
.offset_bv = {{ .offset_in = _bvin, .offset_out = _bvout }}

Referenced by configure_isp().

#define AVI_ISP_IOGET_OFFSETS   _IOR('F', 0x33, struct avi_isp_offsets)

Definition at line 27 of file libisp.c.

Referenced by avi_isp_get_offsets_fd().

#define AVI_MASK   (AVI_SIZE - 1)

Definition at line 15 of file libisp.c.

Referenced by open_isp_fd().

#define AVI_SIZE   0x100000

Definition at line 14 of file libisp.c.

Referenced by close_isp(), and open_isp_fd().

#define COMPLEMENT_2 (   i,
 
)    (((i) >= 0) ? (r) : (~(r) + 1) & 0x3fff)
#define EXPAND_AS_FUNCTION (   _node)
Value:
void avi_isp_ ## _node ## _set_registers(struct libisp_context *c, \
struct avi_isp_ ## _node ## _regs const *regs) \
{ \
memcpy_to_registers(c->offsets[_node], regs, sizeof(*regs)); \
} \
\
void avi_isp_ ## _node ## _get_registers(struct libisp_context *c, \
struct avi_isp_ ## _node ## _regs *regs) \
{ \
memcpy_from_registers(regs, c->offsets[_node], sizeof(*regs)); \
}
static void memcpy_to_registers(unsigned long addr, const void *reg_base, size_t s)
Definition: libisp.c:260
static void memcpy_from_registers(void *reg_base, unsigned long addr, size_t s)
Definition: libisp.c:273

Definition at line 286 of file libisp.c.

#define Q311 (   i)    (COMPLEMENT_2(i, (unsigned)(((ABS(i)) * (1 << 11)) + 0.5)))
#define readl (   _addr)    (*((volatile uint32_t *)(_addr)))

Definition at line 30 of file libisp.c.

Referenced by memcpy_from_registers().

#define writel (   _val,
  _addr 
)    (*((volatile uint32_t *)(_addr)) = _val)

Definition at line 31 of file libisp.c.

Referenced by memcpy_to_registers().

Function Documentation

static int avi_isp_get_offsets_fd ( int  fd,
struct avi_isp_offsets off 
)
static

This is taken from libisp.

Original function takes the videodev name and re-opens it, causing undefined behaviour. Here we reuse the already-opened file descriptor

Definition at line 72 of file libisp.c.

References AVI_ISP_IOGET_OFFSETS.

Referenced by open_isp_fd().

+ Here is the caller graph for this function:

static int close_isp ( struct libisp_context ctx)
static

Definition at line 140 of file libisp.c.

References libisp_context::avi_base, AVI_SIZE, and libisp_context::devmem.

Referenced by configure_isp().

+ Here is the caller graph for this function:

static void memcpy_from_registers ( void *  reg_base,
unsigned long  addr,
size_t  s 
)
inlinestatic

Definition at line 273 of file libisp.c.

References readl.

static void memcpy_to_registers ( unsigned long  addr,
const void *  reg_base,
size_t  s 
)
inlinestatic

Definition at line 260 of file libisp.c.

References writel.

static int open_isp_fd ( struct libisp_context ctx,
int  fd 
)
static

This is taken from libisp.

Original function takes the videodev name and re-opens it, causing undefined behaviour. Here we reuse the already-opened file descriptor

Definition at line 87 of file libisp.c.

References AVI_BASE, libisp_context::avi_base, avi_isp_get_offsets_fd(), AVI_MASK, AVI_SIZE, avi_isp_offsets::chain_bayer, avi_isp_offsets::chain_yuv, avi_isp_offsets::chroma, libisp_context::devmem, avi_isp_offsets::gamma_corrector, isp_bases, ISP_NODE_NR, libisp_context::offsets, and avi_isp_offsets::statistics_yuv.

Referenced by configure_isp().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const unsigned isp_bases[]
static

Definition at line 33 of file libisp.c.

Referenced by open_isp_fd().