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
7235a848
Commit
7235a848
authored
May 14, 2016
by
Mikhail Karpenko
Browse files
Options
Browse Files
Download
Plain Diff
Merge testing branch 'cache'
parents
b9f26a29
9cf40ee6
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
282 additions
and
34 deletions
+282
-34
Makefile
src/drivers/elphel/Makefile
+1
-0
circbuf.c
src/drivers/elphel/circbuf.c
+33
-3
circbuf.h
src/drivers/elphel/circbuf.h
+2
-0
elphel393-mem.c
src/drivers/elphel/elphel393-mem.c
+50
-0
sensor_common.c
src/drivers/elphel/sensor_common.c
+107
-30
sensor_common.h
src/drivers/elphel/sensor_common.h
+1
-1
x393_helpers.c
src/drivers/elphel/x393_helpers.c
+51
-0
x393_helpers.h
src/drivers/elphel/x393_helpers.h
+36
-0
c313a.h
src/include/elphel/c313a.h
+1
-0
No files found.
src/drivers/elphel/Makefile
View file @
7235a848
...
@@ -14,6 +14,7 @@ obj-$(CONFIG_ELPHEL393) += clock10359.o
...
@@ -14,6 +14,7 @@ obj-$(CONFIG_ELPHEL393) += clock10359.o
#fpgajtag-y := fpgajtag353.o x393.o
#fpgajtag-y := fpgajtag353.o x393.o
#obj-$(CONFIG_ELPHEL393_EXTERNAL) += fpgajtag.o
#obj-$(CONFIG_ELPHEL393_EXTERNAL) += fpgajtag.o
obj-$(CONFIG_ELPHEL393)
+=
x393_helpers.o
obj-$(CONFIG_ELPHEL393)
+=
framepars.o
obj-$(CONFIG_ELPHEL393)
+=
framepars.o
obj-$(CONFIG_ELPHEL393)
+=
sensor_common.o
x393.o
obj-$(CONFIG_ELPHEL393)
+=
sensor_common.o
x393.o
obj-$(CONFIG_ELPHEL393)
+=
quantization_tables.o
obj-$(CONFIG_ELPHEL393)
+=
quantization_tables.o
...
...
src/drivers/elphel/circbuf.c
View file @
7235a848
...
@@ -69,7 +69,8 @@
...
@@ -69,7 +69,8 @@
#include "circbuf.h"
#include "circbuf.h"
#include "exif.h"
#include "exif.h"
#include "x393_macro.h"
#include "x393_macro.h"
#include "x393.h"
//#include "x393.h"
#include "x393_helpers.h"
#define CIRCBUF_DRIVER_NAME "circbuf driver"
#define CIRCBUF_DRIVER_NAME "circbuf driver"
...
@@ -184,8 +185,8 @@ loff_t circbuf_all_lseek(struct file *file, loff_t offset, int orig)
...
@@ -184,8 +185,8 @@ loff_t circbuf_all_lseek(struct file *file, loff_t offset, int orig)
return
circbuf_lseek
(
file
,
offset
,
orig
);
return
circbuf_lseek
(
file
,
offset
,
orig
);
case
JPEGHEAD_MINOR
:
case
JPEGHEAD_MINOR
:
if
(
orig
==
SEEK_END
&&
offset
>
0
)
{
if
(
orig
==
SEEK_END
&&
offset
>
0
)
{
rp
=
BYTE2DW
(
offset
)
&
(
~
7
);
// convert to index to long, align to 32-bytes
rp
=
BYTE2DW
(
X393_BUFFSUB
(
offset
,
CHUNK_SIZE
)
)
&
(
~
7
);
// convert to index to long, align to 32-bytes
fp
=
(
struct
interframe_params_t
*
)
&
circbuf_priv
[
chn
].
buf_ptr
[
X393_BUFFSUB
(
rp
,
8
)
];
fp
=
(
struct
interframe_params_t
*
)
&
circbuf_priv
[
chn
].
buf_ptr
[
rp
];
}
}
return
jpeghead_lseek
(
file
,
offset
,
orig
,
fp
);
return
jpeghead_lseek
(
file
,
offset
,
orig
,
fp
);
case
HUFFMAN_MINOR
:
case
HUFFMAN_MINOR
:
...
@@ -416,6 +417,8 @@ inline int get_image_start(int last_chunk_offset, unsigned int len32)
...
@@ -416,6 +417,8 @@ inline int get_image_start(int last_chunk_offset, unsigned int len32)
* free memory may be less by a whole frame if compressor is running.
* free memory may be less by a whole frame if compressor is running.
* LSEEK_CIRC_USED - returns memory used in the in circbuf from the current file pointer,
* LSEEK_CIRC_USED - returns memory used in the in circbuf from the current file pointer,
* or -EINVAL if the pointer is invalid
* or -EINVAL if the pointer is invalid
* The following command is used for profiling from user space applications. It does not change file pointer:
* LSEEK_CIRC_UTIME return current value of microsecond counter.
* @param[in] file pointer to \e file structure
* @param[in] file pointer to \e file structure
* @param[in] offset offset inside buffer in bytes
* @param[in] offset offset inside buffer in bytes
* @param[in] orig origin
* @param[in] orig origin
...
@@ -656,6 +659,9 @@ loff_t circbuf_lseek(struct file *file, loff_t offset, int orig)
...
@@ -656,6 +659,9 @@ loff_t circbuf_lseek(struct file *file, loff_t offset, int orig)
}
}
if
(
fvld
<
0
)
return
-
ESPIPE
;
// invalid seek - have better code?
if
(
fvld
<
0
)
return
-
ESPIPE
;
// invalid seek - have better code?
return
file
->
f_pos
;
// data already available, return file pointer
return
file
->
f_pos
;
// data already available, return file pointer
case
LSEEK_CIRC_UTIME
:
return
get_rtc_usec
();
break
;
default:
default:
if
((
offset
&
~
0x1f
)
==
LSEEK_DAEMON_CIRCBUF
)
{
if
((
offset
&
~
0x1f
)
==
LSEEK_DAEMON_CIRCBUF
)
{
wait_event_interruptible
(
circbuf_wait_queue
,
get_imageParamsThis
(
P_DAEMON_EN
)
&
(
1
<<
(
offset
&
0x1f
)));
wait_event_interruptible
(
circbuf_wait_queue
,
get_imageParamsThis
(
P_DAEMON_EN
)
&
(
1
<<
(
offset
&
0x1f
)));
...
@@ -686,6 +692,8 @@ loff_t circbuf_lseek(struct file *file, loff_t offset, int orig)
...
@@ -686,6 +692,8 @@ loff_t circbuf_lseek(struct file *file, loff_t offset, int orig)
* @return number of bytes read form \e buf
* @return number of bytes read form \e buf
*/
*/
unsigned
short
circbuf_quality
=
100
;
unsigned
short
circbuf_quality
=
100
;
unsigned
short
circbuf_height
=
1936
;
unsigned
short
circbuf_width
=
2592
;
ssize_t
circbuf_write
(
struct
file
*
file
,
const
char
*
buf
,
size_t
count
,
loff_t
*
off
)
ssize_t
circbuf_write
(
struct
file
*
file
,
const
char
*
buf
,
size_t
count
,
loff_t
*
off
)
{
{
unsigned
long
p
;
unsigned
long
p
;
...
@@ -740,6 +748,17 @@ ssize_t circbuf_write(struct file *file, const char *buf, size_t count, loff_t *
...
@@ -740,6 +748,17 @@ ssize_t circbuf_write(struct file *file, const char *buf, size_t count, loff_t *
}
}
}
}
break
;
break
;
case
6
:
{
unsigned
int
w
,
h
;
int
res
=
sscanf
(
&
buf
[
2
],
"%u:%u"
,
&
w
,
&
h
);
if
(
res
==
2
)
{
circbuf_width
=
w
;
circbuf_height
=
h
;
dev_dbg
(
g_dev_ptr
,
"set image size %u x %u
\n
"
,
w
,
h
);
}
}
break
;
}
}
/* debug code end */
/* debug code end */
...
@@ -804,6 +823,17 @@ int circbuf_mmap(struct file *file, struct vm_area_struct *vma)
...
@@ -804,6 +823,17 @@ int circbuf_mmap(struct file *file, struct vm_area_struct *vma)
vma
->
vm_end
-
vma
->
vm_start
,
vma
->
vm_end
-
vma
->
vm_start
,
vma
->
vm_page_prot
);
vma
->
vm_page_prot
);
// ret = dma_common_mmap(g_dev_ptr, vma,
// circbuf_priv[chn].buf_ptr,
// circbuf_priv[chn].phys_addr,
// pElphel_buf->size * PAGE_SIZE);
//
// ret = arm_dma_mmap(g_dev_ptr, vma,
// circbuf_priv[chn].buf_ptr,
// circbuf_priv[chn].phys_addr,
// pElphel_buf->size * PAGE_SIZE,
// NULL);
dev_dbg
(
g_dev_ptr
,
"remap_pfn_range returned 0x%x
\n
"
,
ret
);
dev_dbg
(
g_dev_ptr
,
"remap_pfn_range returned 0x%x
\n
"
,
ret
);
if
(
ret
)
return
-
EAGAIN
;
if
(
ret
)
return
-
EAGAIN
;
...
...
src/drivers/elphel/circbuf.h
View file @
7235a848
...
@@ -44,6 +44,8 @@ extern struct circbuf_priv_t *circbuf_priv_ptr;
...
@@ -44,6 +44,8 @@ extern struct circbuf_priv_t *circbuf_priv_ptr;
/* debug code follows */
/* debug code follows */
extern
unsigned
short
circbuf_quality
;
extern
unsigned
short
circbuf_quality
;
extern
unsigned
short
circbuf_height
;
extern
unsigned
short
circbuf_width
;
/* end of debug code */
/* end of debug code */
#endif
/* _CIRCBUF_H */
#endif
/* _CIRCBUF_H */
src/drivers/elphel/elphel393-mem.c
View file @
7235a848
...
@@ -37,6 +37,8 @@
...
@@ -37,6 +37,8 @@
#include <asm/outercache.h>
#include <asm/outercache.h>
#include <asm/cacheflush.h>
#include <asm/cacheflush.h>
#include <elphel/elphel393-mem.h>
#include <elphel/elphel393-mem.h>
#include "x393_helpers.h"
#define SYSFS_PERMISSIONS 0644
/* default permissions for sysfs files */
#define SYSFS_PERMISSIONS 0644
/* default permissions for sysfs files */
#define SYSFS_READONLY 0444
#define SYSFS_READONLY 0444
#define SYSFS_WRITEONLY 0222
#define SYSFS_WRITEONLY 0222
...
@@ -311,6 +313,47 @@ static ssize_t sync_for_device_bidir(struct device *dev, struct device_attribute
...
@@ -311,6 +313,47 @@ static ssize_t sync_for_device_bidir(struct device *dev, struct device_attribute
return
count
;
return
count
;
}
}
static
ssize_t
flush_cpu_cache
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
const
char
*
buf
,
size_t
count
)
{
const
int
buff_size
=
0x1000000
;
const
int
buff_start_offset
=
0x100000
;
unsigned
int
chn
;
int
start_offset
,
end_offset
;
int
num_items
;
dma_addr_t
phys_addr_start
,
phys_addr_end
;
u32
start_time
,
end_time
;
num_items
=
sscanf
(
buf
,
"%u:%d:%d"
,
&
chn
,
&
start_offset
,
&
end_offset
);
start_time
=
get_rtc_usec
();
if
(
num_items
==
3
)
{
// invalidate L2 caches
if
(
end_offset
>
start_offset
)
{
// handle single buffer case
phys_addr_start
=
_elphel_buf
.
paddr
+
buff_start_offset
+
chn
*
buff_size
+
start_offset
;
phys_addr_end
=
_elphel_buf
.
paddr
+
buff_start_offset
+
chn
*
buff_size
+
end_offset
-
1
;
outer_inv_range
(
phys_addr_start
,
phys_addr_end
);
}
else
{
// handle split buffer case when pointer rolls over the end
// first, process the peace at the end of the buffer
phys_addr_start
=
_elphel_buf
.
paddr
+
buff_start_offset
+
chn
*
buff_size
+
start_offset
;
phys_addr_end
=
_elphel_buf
.
paddr
+
buff_start_offset
+
++
chn
*
buff_size
-
1
;
outer_inv_range
(
phys_addr_start
,
phys_addr_end
);
// second, process the peace at the start of the buffer
phys_addr_start
=
_elphel_buf
.
paddr
+
buff_start_offset
+
chn
*
buff_size
;
phys_addr_end
=
_elphel_buf
.
paddr
+
buff_start_offset
+
chn
*
buff_size
+
end_offset
-
1
;
outer_inv_range
(
phys_addr_start
,
phys_addr_end
);
}
}
end_time
=
get_rtc_usec
();
if
(
start_time
==
0
&&
end_time
==
0
)
{
pr_info
(
"Unable to get usec values
\n
"
);
}
else
{
pr_info
(
"Cache invalidate time: %lu
\n
"
,
end_time
-
start_time
);
}
return
count
;
}
static
ssize_t
get_sync_for_device_h2d
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
static
ssize_t
get_sync_for_device_h2d
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
{
return
sprintf
(
buf
,
"Write address/length pair into this file to hand this region of the host to device DMA buffer to device (after CPU writes).
\n
"
);
return
sprintf
(
buf
,
"Write address/length pair into this file to hand this region of the host to device DMA buffer to device (after CPU writes).
\n
"
);
...
@@ -335,6 +378,11 @@ static ssize_t get_sync_for_cpu_bidir(struct device *dev, struct device_attribut
...
@@ -335,6 +378,11 @@ static ssize_t get_sync_for_cpu_bidir(struct device *dev, struct device_attribut
{
{
return
sprintf
(
buf
,
"Write address/length pair into this file to hand this region of the bidirectional DMA buffer to CPU (before CPU reads).
\n
"
);
return
sprintf
(
buf
,
"Write address/length pair into this file to hand this region of the bidirectional DMA buffer to CPU (before CPU reads).
\n
"
);
}
}
static
ssize_t
get_flush_cpu_cache
(
struct
device
*
dev
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
return
sprintf
(
buf
,
"Write command and address into this file to flush CPU caches. Format 'chn:start_offset:end_offset' where "
"'chn' is sensor channel, 'start_offset' and 'end_offset' are start and end data offsets in circbuf
\n
"
);
}
static
DEVICE_ATTR
(
buffer_address
,
SYSFS_PERMISSIONS
&
SYSFS_READONLY
,
get_paddr
,
NULL
);
static
DEVICE_ATTR
(
buffer_address
,
SYSFS_PERMISSIONS
&
SYSFS_READONLY
,
get_paddr
,
NULL
);
static
DEVICE_ATTR
(
buffer_pages
,
SYSFS_PERMISSIONS
&
SYSFS_READONLY
,
get_size
,
NULL
);
static
DEVICE_ATTR
(
buffer_pages
,
SYSFS_PERMISSIONS
&
SYSFS_READONLY
,
get_size
,
NULL
);
...
@@ -351,6 +399,7 @@ static DEVICE_ATTR(sync_for_cpu_d2h, SYSFS_PERMISSIONS,
...
@@ -351,6 +399,7 @@ static DEVICE_ATTR(sync_for_cpu_d2h, SYSFS_PERMISSIONS,
static
DEVICE_ATTR
(
sync_for_device_d2h
,
SYSFS_PERMISSIONS
,
get_sync_for_device_d2h
,
sync_for_device_d2h
);
static
DEVICE_ATTR
(
sync_for_device_d2h
,
SYSFS_PERMISSIONS
,
get_sync_for_device_d2h
,
sync_for_device_d2h
);
static
DEVICE_ATTR
(
sync_for_cpu_bidir
,
SYSFS_PERMISSIONS
,
get_sync_for_cpu_bidir
,
sync_for_cpu_bidir
);
static
DEVICE_ATTR
(
sync_for_cpu_bidir
,
SYSFS_PERMISSIONS
,
get_sync_for_cpu_bidir
,
sync_for_cpu_bidir
);
static
DEVICE_ATTR
(
sync_for_device_bidir
,
SYSFS_PERMISSIONS
,
get_sync_for_device_bidir
,
sync_for_device_bidir
);
static
DEVICE_ATTR
(
sync_for_device_bidir
,
SYSFS_PERMISSIONS
,
get_sync_for_device_bidir
,
sync_for_device_bidir
);
static
DEVICE_ATTR
(
flush_cpu_cache
,
SYSFS_PERMISSIONS
,
get_flush_cpu_cache
,
flush_cpu_cache
);
static
struct
attribute
*
root_dev_attrs
[]
=
{
static
struct
attribute
*
root_dev_attrs
[]
=
{
&
dev_attr_buffer_address
.
attr
,
&
dev_attr_buffer_address
.
attr
,
...
@@ -368,6 +417,7 @@ static struct attribute *root_dev_attrs[] = {
...
@@ -368,6 +417,7 @@ static struct attribute *root_dev_attrs[] = {
&
dev_attr_sync_for_device_d2h
.
attr
,
&
dev_attr_sync_for_device_d2h
.
attr
,
&
dev_attr_sync_for_cpu_bidir
.
attr
,
&
dev_attr_sync_for_cpu_bidir
.
attr
,
&
dev_attr_sync_for_device_bidir
.
attr
,
&
dev_attr_sync_for_device_bidir
.
attr
,
&
dev_attr_flush_cpu_cache
.
attr
,
NULL
NULL
};
};
...
...
src/drivers/elphel/sensor_common.c
View file @
7235a848
This diff is collapsed.
Click to expand it.
src/drivers/elphel/sensor_common.h
View file @
7235a848
src/drivers/elphel/x393_helpers.c
0 → 100644
View file @
7235a848
/** @file x393_helpers.c
*
* @brief Helper functions for various routines form x393.h which require several actions to get
* reliable result.
*/
/* Copyright (C) 2016 Elphel, Inc
*
* 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 <stddef.h>
#include "x393_helpers.h"
/**
* @brief Read RTC microsecond counter.
* @return Current value of microsecond counter or 0 in case read sequence was
* not successful.
*/
u32
get_rtc_usec
(
void
)
{
x393_rtc_status_t
stat
;
x393_status_ctrl_t
stat_ctrl
;
x393_rtc_usec_t
usec
;
unsigned
int
i
;
stat
=
x393_rtc_status
();
stat_ctrl
.
d32
=
0
;
stat_ctrl
.
mode
=
1
;
stat_ctrl
.
seq_num
=
stat
.
seq_num
+
1
;
set_x393_rtc_set_status
(
stat_ctrl
);
for
(
i
=
0
;
i
<
REPEAT_READ
;
i
++
)
{
stat
=
x393_rtc_status
();
if
(
stat
.
seq_num
==
stat_ctrl
.
seq_num
)
{
usec
=
x393_rtc_status_usec
();
return
usec
.
usec
;
}
}
return
0
;
}
src/drivers/elphel/x393_helpers.h
0 → 100644
View file @
7235a848
/** @file x393_helpers.h
*
* @brief Helper functions for various routines form x393.h which require several actions to get
* reliable result.
*/
/* Copyright (C) 2016 Elphel, Inc
*
* 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/>.
*/
#ifndef _X393_HELPERS_H
#define _X393_HELPERS_H
#include <asm/types.h>
#include "x393.h"
/** @brief Number of times to repeat register read sequence while waiting for
* sequence number specified.
*/
#define REPEAT_READ 10
u32
get_rtc_usec
(
void
);
#endif
/* _X393_HELPERS_H */
src/include/elphel/c313a.h
View file @
7235a848
...
@@ -1362,6 +1362,7 @@ struct p_names_t {
...
@@ -1362,6 +1362,7 @@ struct p_names_t {
#define LSEEK_CIRC_FREE 12
#define LSEEK_CIRC_FREE 12
#define LSEEK_CIRC_USED 13
#define LSEEK_CIRC_USED 13
#define LSEEK_CIRC_STOP_COMPRESSOR 14
#define LSEEK_CIRC_STOP_COMPRESSOR 14
#define LSEEK_CIRC_UTIME 15
#define LSEEK_HUFFMAN_DC0 1
#define LSEEK_HUFFMAN_DC0 1
#define LSEEK_HUFFMAN_AC0 2
#define LSEEK_HUFFMAN_AC0 2
...
...
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