Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.0 on 2022-01-18 at 14:00 UTC+1 (a few minutes of down time)

Commit e3b506c4 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

Merged lua_fix into crop_rec_4k

(memset32 fix, DIGIC identification, minor fixes)

--HG--
branch : crop_rec_4k
......@@ -24,7 +24,7 @@ all_silent: $(MODULES_ALL_TARGETS_DELETE_IF_FAILED)
# run module-specific clean rules
# also run a generic clean, just in case there are any modules left over
clean: $(MODULES_CLEAN_ALL_TARGETS)
$(call rm_files, $(addprefix $(MODULES_DIR)/, *.o *.d *.dep *.sym hgstamp))
$(call rm_files, $(addprefix $(MODULES_DIR)/, */*.mo */*.o */*.d */*.dep */*.sym */module_strings.h */hgstamp */hginfo.tmp))
install: | prepare_install_dir
install: all
......
......@@ -179,48 +179,6 @@ static uint32_t FAST DUMP_ASM mem_test_read32(uint32_t* buf, uint32_t n)
return tmp;
}
/**
* 5D3 cacheable uncacheable
* newlib memset: 237MB/s 100MB/s
* memset64 : 194MB/s (!) 130MB/s
*/
static void* FAST memset64(void* dest, int val, size_t n)
{
/* seems to accept 32-bit aligned pointers */
ASSERT(((intptr_t)dest & 3) == 0);
ASSERT((n & 7) == 0);
uint64_t v1 = ((uint64_t) val) & 0xFFFFFFFFull;
uint64_t v = v1 << 32 | v1;
uint64_t* dst = (uint64_t*) dest;
for(size_t i = 0; i < n/8; i++)
*dst++ = v;
return (void*)dest;
}
/**
* 5D3 cacheable uncacheable
* newlib memcpy: 75MB/s 17MB/s
* diet memcpy : 19MB/s 4MB/s
* memcpy64 : 80MB/s 32MB/s
*/
static void * FAST memcpy64(void* dest, void* srce, size_t n)
{
/* seems to accept 32-bit aligned pointers */
ASSERT(((intptr_t)dest & 3) == 0);
ASSERT(((intptr_t)srce & 3) == 0);
ASSERT((n & 7) == 0);
uint64_t* dst = (uint64_t*) dest;
uint64_t* src = (uint64_t*) srce;
for(size_t i = 0; i < n/8; i++)
*dst++ = *src++;
return (void*)dst;
}
static void mem_benchmark_task()
{
......@@ -243,7 +201,6 @@ static void mem_benchmark_task()
void* buf2 = 0;
buf1 = fio_malloc(bufsize);
buf2 = fio_malloc(bufsize);
if (!buf1 || !buf2)
{
bmp_printf(FONT_LARGE, 0, 0, "malloc error :(");
......
......@@ -1094,6 +1094,40 @@ static void stub_test_dryos()
TEST_FUNC_CHECK(ReleaseRecursiveLock(rlock), != 0);
}
static void stub_test_model_id()
{
// model, firmware version
TEST_MSG("[INFO] Camera model: %s %s (0x%X %s)\n", camera_model, firmware_version, camera_model_id, __camera_model_short);
TEST_FUNC_CHECK(is_camera("DIGIC", "*"), == 1);
TEST_FUNC_CHECK(is_camera(__camera_model_short, firmware_version), == 1);
if (is_camera("5D3", "*"))
{
TEST_FUNC_CHECK(is_camera("5D2", "*"), == 0);
TEST_FUNC_CHECK(is_camera("DIGIC", "4"), == 0);
TEST_FUNC_CHECK(is_camera("DIGIC", "5"), == 1);
}
else if (is_camera("60D", "*"))
{
TEST_FUNC_CHECK(is_camera("600D", "*"), == 0);
TEST_FUNC_CHECK(is_camera("DIGIC", "5"), == 0);
TEST_FUNC_CHECK(is_camera("DIGIC", "4"), == 1);
}
else if (is_camera("80D", "*"))
{
TEST_FUNC_CHECK(is_camera("70D", "*"), == 0);
TEST_FUNC_CHECK(is_camera("DIGIC", "5"), == 0);
TEST_FUNC_CHECK(is_camera("DIGIC", "6"), == 1);
}
else if (is_camera("200D", "*"))
{
TEST_FUNC_CHECK(is_camera("100D", "*"), == 0);
TEST_FUNC_CHECK(is_camera("DIGIC", "6"), == 0);
TEST_FUNC_CHECK(is_camera("DIGIC", "7"), == 1);
}
}
static void stub_test_save_log()
{
FILE* log = FIO_CreateFile("ML/LOGS/stubtest.log");
......@@ -1127,6 +1161,7 @@ static void stub_test_task(void* arg)
/* save log after each sub-test */
for (int i=0; i < n; i++)
{
stub_test_model_id(); stub_test_save_log();
stub_test_edmac(); stub_test_save_log();
stub_test_cache(); stub_test_save_log();
stub_test_af(); stub_test_save_log();
......
......@@ -116,6 +116,8 @@ extern void * memset ( void * ptr, int value, size_t num );
extern void* memcpy( void *, const void *, size_t );
extern int memcmp( const void* s1, const void* s2,size_t n );
extern void * memchr( const void *s, int c, size_t n );
extern void* memset64(void* dest, int val, size_t n);
extern void* memcpy64(void* dest, void* srce, size_t n);
extern void* dma_memcpy(void* dest, void* srce, size_t n);
extern void* edmac_memcpy(void* dest, void* srce, size_t n);
......
......@@ -5940,7 +5940,7 @@ static void longpress_check(int timer, void * opaque)
/* optional unpress event */
if (longpress->short_btn_unpress)
{
fake_simple_button(longpress->long_btn_unpress);
fake_simple_button(longpress->short_btn_unpress);
}
}
}
......
......@@ -337,8 +337,9 @@ module_symbol_##NAME = { \
/* for camera-specific tricks in modules */
/* e.g. if (is_camera("5D3", "1.2.3")) { adtg_write_addr = 0x1234 } */
/* also if (is_camera("DIGIC", "5")) { ... } */
/* see propvalues.c */
extern int is_camera(const char * model, const char * firmware);
extern int is_camera(const char * model, const char * version);
#ifdef MODULE
#include "module_strings.h"
......
......@@ -19,11 +19,44 @@ char camera_serial[32];
/* is_camera("5D3", "1.2.3") - will check for a specific camera / firmware version */
/* is_camera("5D3", "*") - will accept all firmware versions */
int is_camera(const char * model, const char * firmware)
/* is_camera("DIGIC", "5") - will accept all DIGIC 5 models */
/* todo: possibly other classifications? */
int is_camera(const char * model, const char * version)
{
if (streq(model, "DIGIC"))
{
if (streq(version, "*"))
{
/* only DIGIC models supported */
return 1;
}
if (strlen(version) != 1)
{
/* only one-digit DIGIC version check is currently supported, i.e. no 4+ or similar */
return 0;
}
#ifdef CONFIG_VXWORKS
return version[0] == '3';
#endif
#ifdef CONFIG_DIGIC_V
return version[0] == '5';
#endif
#ifdef CONFIG_DIGIC_VI
return version[0] == '6';
#endif
#ifdef CONFIG_DIGIC_VII
return version[0] == '7';
#endif
//#ifdef CONFIG_DIGIC_IV - fixme
return version[0] == '4';
//#endif
}
return
streq(__camera_model_short, model) && /* check camera model */
(streq(firmware_version, firmware) || streq(firmware, "*")); /* check firmware version */
streq(__camera_model_short, model) && /* check camera model */
(streq(firmware_version, version) || streq(version, "*")); /* check firmware version */
}
PROP_HANDLER(PROP_CAM_MODEL)
......
......@@ -79,3 +79,47 @@ snprintf(
va_end( ap );
return len;
}
/**
* 5D3 cacheable uncacheable
* newlib memset: 237MB/s 100MB/s
* memset64 : 194MB/s (!) 130MB/s
*/
/* this duplicates 32-bit integers, unlike memset, which converts to char first */
void* FAST memset64(void* dest, int val, size_t n)
{
/* seems to accept 32-bit aligned pointers */
ASSERT(((intptr_t)dest & 3) == 0);
ASSERT((n & 7) == 0);
uint64_t v1 = ((uint64_t) val) & 0xFFFFFFFFull;
uint64_t v = v1 << 32 | v1;
uint64_t* dst = (uint64_t*) dest;
for(size_t i = 0; i < n/8; i++)
*dst++ = v;
return (void*)dest;
}
/**
* 5D3 cacheable uncacheable
* newlib memcpy: 75MB/s 17MB/s
* diet memcpy : 19MB/s 4MB/s
* memcpy64 : 80MB/s 32MB/s
*/
void * FAST memcpy64(void* dest, void* srce, size_t n)
{
/* seems to accept 32-bit aligned pointers */
ASSERT(((intptr_t)dest & 3) == 0);
ASSERT(((intptr_t)srce & 3) == 0);
ASSERT((n & 7) == 0);
uint64_t* dst = (uint64_t*) dest;
uint64_t* src = (uint64_t*) srce;
for(size_t i = 0; i < n/8; i++)
*dst++ = *src++;
return (void*)dst;
}
......@@ -2728,20 +2728,20 @@ static void grayscale_menus_step()
prev_sig = sig;
#ifdef CONFIG_5D3
if (get_yuv422_vram()->vram == 0 && !lv)
{
/* 5D3-123 quirk: YUV422 RAM is not initialized until going to LiveView or Playback mode
* (and even there, you need a valid image first)
* Workaround: if YUV422 was not yet initialized by Canon, remove the transparency from color 0 (make it black).
*
* Any other cameras requiring this? Probably not, since the quirk is likely related to the dual monitor support.
* Any other cameras requiring this? At least 6D shows artifacts in QEMU when running benchmarks
* or playing Arkanoid. 700D and 1100D also have uninitialized buffer. 550D and 600D are OK.
* No side effects on cameras that don't need this workaround => always enabled.
*
* Note: alter_bitmap_palette will not affect color 0, so it will not break this workaround (yet).
*/
alter_bitmap_palette_entry(0, COLOR_BLACK, 256, 256);
}
#endif
if (bmp_color_scheme || prev_b)
{
......
......@@ -3436,6 +3436,9 @@ static void draw_zoom_overlay(int dirty)
break;
}
/* (W<<1) should be 64-bit aligned for memset64 */
W &= ~3;
// Magnification factor
int X = zoom_overlay_x + 1;
......@@ -3479,20 +3482,21 @@ static void draw_zoom_overlay(int dirty)
#endif
w /= X;
h /= X;
w &= ~3; /* (w<<1) should be 64-bit aligned for memset64 */
const int val_in_coerce_w = aff_x0_lv - (w>>1);
const int coerce_w = COERCE(val_in_coerce_w, 0, 720-w);
const int coerce_w = COERCE(val_in_coerce_w, 0, 720-w) & ~1; /* should be 32-bit (2px) aligned for memset64 */
const int val_in_coerce_h1 = aff_y0_lv - (h>>1);
const int val_in_coerce_h2 = aff_y0_lv + (h>>1);
memset(lvr + coerce_w + COERCE(val_in_coerce_h1 - 2, 0, lv->height) * lv->width, MZ_BLACK, w<<1);
memset(lvr + coerce_w + COERCE(val_in_coerce_h1 - 1, 0, lv->height) * lv->width, MZ_WHITE, w<<1);
memset(lvr + coerce_w + COERCE(val_in_coerce_h2 + 1, 0, lv->height) * lv->width, MZ_WHITE, w<<1);
memset(lvr + coerce_w + COERCE(val_in_coerce_h2 + 2, 0, lv->height) * lv->width, MZ_BLACK, w<<1);
memset64(lvr + coerce_w + COERCE(val_in_coerce_h1 - 2, 0, lv->height) * lv->width, MZ_BLACK, w<<1);
memset64(lvr + coerce_w + COERCE(val_in_coerce_h1 - 1, 0, lv->height) * lv->width, MZ_WHITE, w<<1);
memset64(lvr + coerce_w + COERCE(val_in_coerce_h2 + 1, 0, lv->height) * lv->width, MZ_WHITE, w<<1);
memset64(lvr + coerce_w + COERCE(val_in_coerce_h2 + 2, 0, lv->height) * lv->width, MZ_BLACK, w<<1);
}
//~ draw_circle(x0,y0,45,COLOR_WHITE);
int y;
int x0c = COERCE(zb_x0_lv - (W>>1), 0, lv->width-W);
int x0c = COERCE(zb_x0_lv - (W>>1), 0, lv->width-W) & ~1; /* should be 32-bit (2px) aligned for memset64 */
int y0c = COERCE(zb_y0_lv - (H>>1), 0, lv->height-H);
extern int focus_value;
......@@ -3527,16 +3531,17 @@ static void draw_zoom_overlay(int dirty)
#ifdef CONFIG_1100D
H /= 2; //LCD res fix (half height)
#endif
memset(lvr + x0c + COERCE(0 + y0c, 0, 720) * lv->width, rawoff ? MZ_BLACK : MZ_GREEN, W<<1);
memset(lvr + x0c + COERCE(1 + y0c, 0, 720) * lv->width, rawoff ? MZ_WHITE : MZ_GREEN, W<<1);
memset64(lvr + x0c + COERCE(0 + y0c, 0, 720) * lv->width, rawoff ? MZ_BLACK : MZ_GREEN, W<<1);
memset64(lvr + x0c + COERCE(1 + y0c, 0, 720) * lv->width, rawoff ? MZ_WHITE : MZ_GREEN, W<<1);
if (!rawoff) {
memset(lvr + x0c + COERCE(-2 + y0c, 0, 720) * lv->width, MZ_GREEN, W<<1);
memset(lvr + x0c + COERCE(-1 + y0c, 0, 720) * lv->width, MZ_GREEN, W<<1);
memset(lvr + x0c + COERCE(H + y0c, 0, 720) * lv->width, MZ_GREEN, W<<1);
memset(lvr + x0c + COERCE(H+1 + y0c, 0, 720) * lv->width, MZ_GREEN, W<<1);
memset64(lvr + x0c + COERCE(-2 + y0c, 0, 720) * lv->width, MZ_GREEN, W<<1);
memset64(lvr + x0c + COERCE(-1 + y0c, 0, 720) * lv->width, MZ_GREEN, W<<1);
memset64(lvr + x0c + COERCE(H + y0c, 0, 720) * lv->width, MZ_GREEN, W<<1);
memset64(lvr + x0c + COERCE(H+1 + y0c, 0, 720) * lv->width, MZ_GREEN, W<<1);
}
memset(lvr + x0c + COERCE(H-2 + y0c, 0, 720) * lv->width, rawoff ? MZ_WHITE : MZ_GREEN, W<<1);
memset(lvr + x0c + COERCE(H-1 + y0c, 0, 720) * lv->width, rawoff ? MZ_BLACK : MZ_GREEN, W<<1);
memset64(lvr + x0c + COERCE(H-2 + y0c, 0, 720) * lv->width, rawoff ? MZ_WHITE : MZ_GREEN, W<<1);
memset64(lvr + x0c + COERCE(H-1 + y0c, 0, 720) * lv->width, rawoff ? MZ_BLACK : MZ_GREEN, W<<1);
#ifdef CONFIG_1100D
H *= 2; // Undo it
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment