Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
linux-elphel
Commits
e41643e0
Commit
e41643e0
authored
Aug 03, 2016
by
Mikhail Karpenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge read and write code into one command
parent
6a573df8
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1696 additions
and
234 deletions
+1696
-234
ahci_elphel.c
src/drivers/ata/ahci_elphel.c
+1493
-233
ahci_elphel.h
src/drivers/ata/ahci_elphel.h
+114
-0
circbuf.c
src/drivers/elphel/circbuf.c
+31
-0
circbuf.h
src/drivers/elphel/circbuf.h
+9
-0
exif393.c
src/drivers/elphel/exif393.c
+31
-1
exif393.h
src/drivers/elphel/exif393.h
+1
-0
jpeghead.c
src/drivers/elphel/jpeghead.c
+16
-0
jpeghead.h
src/drivers/elphel/jpeghead.h
+1
-0
No files found.
src/drivers/ata/ahci_elphel.c
View file @
e41643e0
This diff is collapsed.
Click to expand it.
src/drivers/ata/ahci_elphel.h
0 → 100644
View file @
e41643e0
/** @file ahci_elphel_ext.h
*
* @brief Elphel AHCI SATA platform driver for Elphel393 camera. This module provides
* additional functions which allows to use a part of a disk (or entire disk) as a
* raw circular buffer.
*
* @copyright Copyright (C) 2016 Elphel, Inc
*
* @par <b>License</b>
* 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
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../elphel/circbuf.h"
#ifndef _AHCI_ELPHEL_EXT
#define _AHCI_ELPHEL_EXT
/** Flag indicating that IRQ should not be processed in ahci_port_interrupt */
#define IRQ_SIMPLE (1 << 0)
/** Processing command in progress */
#define PROC_CMD (1 << 1)
/** Flag indicating that the remaining chunk of data will be recorder */
#define LAST_BLOCK (1 << 2)
/** The length of a command FIS in double words */
#define CMD_FIS_LEN 5
/** This is used to get 28-bit address from 64-bit value */
#define ADDR_MASK_28_BIT ((u64)0xfffffff)
/** An array or JPEG frame chunks contains pointers to JPEG leading marker,
* JPEG header, Exif data if present, stuffing bytes chunk which aligns
* the frame size to disk sector boundary, JPEG data which
* can be split into two chunks, their corresponding align buffers, JPEG
* trailing marker, and pointer to a buffer containing the remainder of a
* frame. Ten chunks of data in total.
* @todo Fix description */
#define MAX_DATA_CHUNKS 10
/** Default port number */
#define DEFAULT_PORT_NUM 0
/** Align buffers length to this amount of bytes */
#define ALIGNMENT_SIZE 32
/** Address alignment boundary */
#define ALIGNMENT_ADDR 2
/** This structure holds raw device buffer pointers */
struct
drv_pointers
{
uint64_t
lba_start
;
///< raw buffer starting LBA
uint64_t
lba_end
;
///< raw buffer ending LBA
uint64_t
lba_write
;
///< current write pointer inside raw buffer
uint16_t
wr_count
;
///< the number of LBA to write next time
};
//struct fvec {
// void *iov_base; ///< pointer to allocated buffer
// size_t iov_len; ///< the size (in bytes) of allocated buffer; set after allocation and is not modified during buffer lifetime
// dma_addr_t iov_dma; ///< buffer physical address
//};
//struct frame_vects {
// struct fvec prev_chunk; ///< remainder chunk of data from previous frame (NOT USED NOW)
// struct fvec header_buff; ///< buffer for JPEG header
// struct fvec leader; ///< JPEG leading marker, pointer to header_buff
// struct fvec exif; ///< pointer to Exif data buffer
// struct fvec header; ///< JPEG header data without leading marker, pointer to header_buff
// struct fvec stuffing; ///< stuffing bytes for frame alignment (WILL BE REMOVED AFTER SPEED TEST)
// struct kvec jpeg[2]; ///< pointers to JPEG frame data which can be split across circular buffer boundary
// struct fvec trailer; ///< JPEG trailing marker
//};
struct
frame_buffers
{
struct
fvec
exif_buff
;
struct
fvec
jpheader_buff
;
struct
fvec
trailer_buff
;
struct
fvec
common_buff
;
struct
fvec
rem_buff
;
///< remainder from previous frame
};
enum
{
CHUNK_LEADER
,
CHUNK_EXIF
,
CHUNK_HEADER
,
CHUNK_COMMON
,
CHUNK_DATA_0
,
CHUNK_ALIGN_0
,
CHUNK_DATA_1
,
CHUNK_ALIGN_1
,
CHUNK_TRAILER
,
CHUNK_REM
};
struct
elphel_ahci_priv
{
u32
clb_offs
;
u32
fb_offs
;
u32
base_addr
;
u32
flags
;
int
curr_cmd
;
size_t
max_data_sz
;
struct
drv_pointers
lba_ptr
;
struct
frame_buffers
fbuffs
;
struct
fvec
data_chunks
[
MAX_DATA_CHUNKS
];
struct
fvec
sgl
[
MAX_DATA_CHUNKS
];
int
sg_elems
;
int
curr_data_chunk
;
///< index of a data chunk used during last transaction
size_t
curr_data_offset
;
///< offset of the last byte in a data chunk pointed to by @e curr_data_chunk
};
#endif
/* _AHCI_ELPHEL_EXT */
src/drivers/elphel/circbuf.c
View file @
e41643e0
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include <linux/platform_device.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_device.h>
#include <linux/uio.h>
#include <asm/uaccess.h>
#include <asm/uaccess.h>
#include <elphel/driver_numbers.h>
#include <elphel/driver_numbers.h>
#include <elphel/c313a.h>
#include <elphel/c313a.h>
...
@@ -99,6 +100,36 @@ int init_ccam_dma_buf_ptr(struct platform_device *pdev)
...
@@ -99,6 +100,36 @@ int init_ccam_dma_buf_ptr(struct platform_device *pdev)
return
0
;
return
0
;
}
}
int
circbuf_get_ptr
(
int
sensor_port
,
size_t
offset
,
size_t
len
,
struct
fvec
*
vect_0
,
struct
fvec
*
vect_1
)
{
int
ret
=
1
;
if
(
offset
>
CCAM_DMA_SIZE
||
sensor_port
>=
SENSOR_PORTS
)
return
-
EINVAL
;
if
(
offset
+
len
<
CCAM_DMA_SIZE
)
{
// the image is not split
vect_0
->
iov_base
=
circbuf_priv
[
sensor_port
].
buf_ptr
+
offset
;
vect_0
->
iov_dma
=
circbuf_priv
[
sensor_port
].
phys_addr
+
offset
;
vect_0
->
iov_len
=
len
;
vect_1
->
iov_base
=
NULL
;
vect_1
->
iov_len
=
0
;
vect_1
->
iov_dma
=
0
;
}
else
{
// the image is split into two segments
vect_0
->
iov_base
=
circbuf_priv
[
sensor_port
].
buf_ptr
+
offset
;
vect_0
->
iov_dma
=
circbuf_priv
[
sensor_port
].
phys_addr
+
offset
;
vect_0
->
iov_len
=
CCAM_DMA_SIZE
-
offset
;
vect_1
->
iov_base
=
circbuf_priv
[
sensor_port
].
buf_ptr
;
vect_1
->
iov_dma
=
circbuf_priv
[
sensor_port
].
phys_addr
;
vect_1
->
iov_len
=
len
-
vect_0
->
iov_len
;
ret
=
2
;
}
return
ret
;
}
EXPORT_SYMBOL_GPL
(
circbuf_get_ptr
);
/**
/**
* @brief Process circular buffer file opening and define further action in accordance
* @brief Process circular buffer file opening and define further action in accordance
* with minor file number.
* with minor file number.
...
...
src/drivers/elphel/circbuf.h
View file @
e41643e0
...
@@ -55,4 +55,13 @@ extern unsigned short circbuf_width;
...
@@ -55,4 +55,13 @@ extern unsigned short circbuf_width;
extern
unsigned
char
circbuf_byrshift
;
extern
unsigned
char
circbuf_byrshift
;
/* end of debug code */
/* end of debug code */
/* this should be placed to drivers common includes */
struct
fvec
{
void
*
iov_base
;
///< pointer to allocated buffer
size_t
iov_len
;
///< the size (in bytes) of allocated buffer; set after allocation and is not modified during buffer lifetime
dma_addr_t
iov_dma
;
///< buffer physical address
};
/* end of common includes */
int
circbuf_get_ptr
(
int
sensor_port
,
size_t
offset
,
size_t
len
,
struct
fvec
*
vect_0
,
struct
fvec
*
vect_1
);
#endif
/* _CIRCBUF_H */
#endif
/* _CIRCBUF_H */
src/drivers/elphel/exif393.c
View file @
e41643e0
...
@@ -82,7 +82,7 @@
...
@@ -82,7 +82,7 @@
#include "exif393.h"
#include "exif393.h"
#define D(x)
#define D(x)
//#define D(x) printk("%s:%d:",__FILE__,__LINE__);x
//#define D(x) printk("
>>>
%s:%d:",__FILE__,__LINE__);x
//Major
//Major
...
@@ -115,6 +115,7 @@ static int aexif_wp[SENSOR_PORTS] = {1,1,1,1}; // frame write pointer in
...
@@ -115,6 +115,7 @@ static int aexif_wp[SENSOR_PORTS] = {1,1,1,1}; // frame write pointer in
static
int
aexif_enabled
[
SENSOR_PORTS
]
=
{
0
,
0
,
0
,
0
};
// enable storing of frame meta data, enable reading Exif data
static
int
aexif_enabled
[
SENSOR_PORTS
]
=
{
0
,
0
,
0
,
0
};
// enable storing of frame meta data, enable reading Exif data
static
int
aexif_valid
[
SENSOR_PORTS
]
=
{
0
,
0
,
0
,
0
};
// Exif tables and buffer are valid.
static
int
aexif_valid
[
SENSOR_PORTS
]
=
{
0
,
0
,
0
,
0
};
// Exif tables and buffer are valid.
static
char
*
ameta_buffer
[
SENSOR_PORTS
]
=
{
NULL
,
NULL
,
NULL
,
NULL
};
// dynamically allocated buffer to store frame meta data.
static
char
*
ameta_buffer
[
SENSOR_PORTS
]
=
{
NULL
,
NULL
,
NULL
,
NULL
};
// dynamically allocated buffer to store frame meta data.
static
char
exif_tmp_buff
[
MAX_EXIF_SIZE
];
//static char * meta_buffer=NULL; // dynamically allocated buffer to store frame meta data.
//static char * meta_buffer=NULL; // dynamically allocated buffer to store frame meta data.
// page 0 - temporary storage, 1..MAX_EXIF_FRAMES - buffer
// page 0 - temporary storage, 1..MAX_EXIF_FRAMES - buffer
...
@@ -741,6 +742,35 @@ static ssize_t exif_read (struct file * file, char * buf, size_t count, lof
...
@@ -741,6 +742,35 @@ static ssize_t exif_read (struct file * file, char * buf, size_t count, lof
return
count
;
return
count
;
}
}
/* This code is copied from exif_read, consider replacing it with this function invocation */
size_t
exif_get_data
(
int
sensor_port
,
unsigned
short
meta_index
,
void
*
buff
,
size_t
buff_sz
)
{
size_t
ret
=
0
;
size_t
count
=
exif_template_size
;
loff_t
off
;
int
start_p
,
page_p
,
i
;
char
*
metap
;
//will truncate by the end of current page
if
(
!
aexif_enabled
[
sensor_port
])
return
0
;
off
=
meta_index
*
exif_template_size
;
D
(
printk
(
"%s: count= 0x%x, *off= 0x%x, i=0x%x, exif_template_size=0x%x
\n
"
,
__func__
,
(
int
)
count
,
(
int
)
off
,
(
int
)
meta_index
,
(
int
)
exif_template_size
));
start_p
=
meta_index
*
exif_template_size
;
page_p
=
off
-
start_p
;
D
(
printk
(
"%s: count= 0x%x, pos= 0x%x, start_p=0x%x, page_p=0x%x, i=0x%x, exif_template_size=0x%x
\n
"
,
__func__
,
(
int
)
count
,
(
int
)
off
,
(
int
)
start_p
,
(
int
)
page_p
,(
int
)
meta_index
,
(
int
)
exif_template_size
));
metap
=
&
ameta_buffer
[
sensor_port
][
meta_index
*
aexif_meta_size
[
sensor_port
]];
// pointer to the start of the selected page in frame meta_buffer
if
((
page_p
+
count
)
>
exif_template_size
)
count
=
exif_template_size
-
page_p
;
memcpy
(
exif_tmp_buff
,
exif_template
,
exif_template_size
);
D
(
printk
(
"%s: count= 0x%x, pos= 0x%x, start_p=0x%x, page_p=0x%x
\n
"
,
__func__
,
(
int
)
count
,
(
int
)
off
,
(
int
)
start_p
,
(
int
)
page_p
));
for
(
i
=
0
;
i
<
exif_fields
;
i
++
)
{
memcpy
(
&
exif_tmp_buff
[
dir_table
[
i
].
dst
],
&
metap
[
dir_table
[
i
].
src
],
dir_table
[
i
].
len
);
}
memcpy
(
buff
,
&
exif_tmp_buff
[
page_p
],
count
);
return
count
;
}
EXPORT_SYMBOL_GPL
(
exif_get_data
);
//!++++++++++++++++++++++++++++++++++++ _init() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
//!++++++++++++++++++++++++++++++++++++ _init() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
...
...
src/drivers/elphel/exif393.h
View file @
e41643e0
...
@@ -40,5 +40,6 @@ int putlong_meta(int sensor_port, unsigned long data, int * indx, unsigned long
...
@@ -40,5 +40,6 @@ int putlong_meta(int sensor_port, unsigned long data, int * indx, unsigned long
char
*
encode_time
(
char
buf
[
27
],
unsigned
long
sec
,
unsigned
long
usec
);
char
*
encode_time
(
char
buf
[
27
],
unsigned
long
sec
,
unsigned
long
usec
);
int
store_meta
(
int
sensor_port
);
//called from IRQ service - put current metadata to meta_buffer, return page index
int
store_meta
(
int
sensor_port
);
//called from IRQ service - put current metadata to meta_buffer, return page index
size_t
exif_get_data
(
int
sensor_port
,
unsigned
short
meta_index
,
void
*
buff
,
size_t
buff_sz
);
#endif
#endif
src/drivers/elphel/jpeghead.c
View file @
e41643e0
...
@@ -412,6 +412,22 @@ ssize_t jpeghead_read(struct file *file, char *buf, size_t count, loff_t *off)
...
@@ -412,6 +412,22 @@ ssize_t jpeghead_read(struct file *file, char *buf, size_t count, loff_t *off)
return
count
;
return
count
;
}
}
ssize_t
jpeghead_get_data
(
int
sensor_port
,
void
*
buff
,
size_t
buff_sz
,
size_t
offset
)
{
unsigned
long
ptr
=
offset
;
size_t
count
=
jpeghead_priv
[
sensor_port
].
jpeg_h_sz
;
if
(
ptr
>=
jpeghead_priv
[
sensor_port
].
jpeg_h_sz
)
ptr
=
jpeghead_priv
[
sensor_port
].
jpeg_h_sz
;
if
((
ptr
+
count
)
>
jpeghead_priv
[
sensor_port
].
jpeg_h_sz
)
count
=
jpeghead_priv
[
sensor_port
].
jpeg_h_sz
-
ptr
;
if
(
buff_sz
<
count
)
return
-
EINVAL
;
memcpy
(
buff
,
&
jpeghead_priv
[
sensor_port
].
header
[
ptr
],
count
);
return
count
;
}
EXPORT_SYMBOL_GPL
(
jpeghead_get_data
);
/**huffman_* file operations
/**huffman_* file operations
* write, read Huffman tables, initialize tables to default ones, program FPGA with the Huffman tables
* write, read Huffman tables, initialize tables to default ones, program FPGA with the Huffman tables
...
...
src/drivers/elphel/jpeghead.h
View file @
e41643e0
...
@@ -14,6 +14,7 @@ int jpegheader_create(struct interframe_params_t * params, unsigned char * b
...
@@ -14,6 +14,7 @@ int jpegheader_create(struct interframe_params_t * params, unsigned char * b
int
jpeghead_open
(
struct
inode
*
inode
,
struct
file
*
filp
);
// set filesize
int
jpeghead_open
(
struct
inode
*
inode
,
struct
file
*
filp
);
// set filesize
loff_t
jpeghead_lseek
(
struct
file
*
file
,
loff_t
offset
,
int
orig
,
struct
interframe_params_t
*
fp
);
loff_t
jpeghead_lseek
(
struct
file
*
file
,
loff_t
offset
,
int
orig
,
struct
interframe_params_t
*
fp
);
ssize_t
jpeghead_read
(
struct
file
*
file
,
char
*
buf
,
size_t
count
,
loff_t
*
off
);
ssize_t
jpeghead_read
(
struct
file
*
file
,
char
*
buf
,
size_t
count
,
loff_t
*
off
);
ssize_t
jpeghead_get_data
(
int
sensor_port
,
void
*
buff
,
size_t
buff_sz
,
size_t
offset
);
int
huffman_open
(
struct
inode
*
inode
,
struct
file
*
filp
);
// set filesize
int
huffman_open
(
struct
inode
*
inode
,
struct
file
*
filp
);
// set filesize
int
huffman_release
(
struct
inode
*
inode
,
struct
file
*
filp
);
int
huffman_release
(
struct
inode
*
inode
,
struct
file
*
filp
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment