Closed pazos closed 5 years ago
More details later when I have access to a computer, but basically, device identification is done in fbink_device_id.c, with device-specific functions hidden behind ifdefs, and that's simply called from fbink_init.
It'll probably need a copy of the mxcfb header, and a dedicated refresh function, too. That stuff lives in fbink.c ;).
If there's nothing fancy in terms of model specific quirks, the whole device_id part may be completely unneeded, and only the refresh matters. If it's ntx hardware, we might even be able to simply recycle the Kobo functions...
That's assuming the framebuffer doesn't lie about what it reports to userspace, which should hold true, with a bit of luck. Ntx is generally sane-ish in that respect, unlike pocketbook crap^Wstuff...
@NiLuJe thanks for the feedback! Do I need to hardcore device resolution somewhere?
here is the code I'm using to differenciate between bq readers
/*
Copyright (C) 2016 Cosmin Gorgovan <okreader at linux-geek dot org>
-- original code https://raw.githubusercontent.com/lgeek/okreader/master/src/kobo_hwconfig/kobo_hwconfig.c
Copyright (C) 2018 Martín Fernández <pazos at gmail dot com>
-- simplified and adapted to Bq e-readers.
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 <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
// hwconfig environment, it is the same for both kobo and bq devices
#define HWCONFIG_DEVICE "/dev/mmcblk0"
#define HWCONFIG_OFFSET (1024 * 512)
#define HWCONFIG_MAGIC "HW CONFIG "
// board ids, from https://github.com/bq/cervantes/blob/master/bqHAL/Devices/mx508/src/DeviceInfoMx508.cpp
#define E606A2_PCBID 22
#define E60672_PCBID 23
#define E60Q22_PCBID 33
#define E60QH2_PCBID 51
#define E60QP2_PCBID 68
typedef struct __attribute__ ((__packed__)) {
char magic[10];
char version[5];
uint8_t size;
uint8_t pcb_id;
} hwconfig;
int main(void) {
hwconfig config;
char* model;
FILE *file;
int ret;
file = fopen(HWCONFIG_DEVICE, "rb");
if (file == NULL)
{
fprintf(stderr, "Failed to open the input file %s\n", HWCONFIG_DEVICE);
exit(EXIT_FAILURE);
}
ret = fseek(file, HWCONFIG_OFFSET, SEEK_SET);
if (ret != 0)
{
fprintf(stderr, "Failed to seek to position 0x%x in %s\n", HWCONFIG_OFFSET, HWCONFIG_DEVICE);
exit(EXIT_FAILURE);
}
ret = fread(&config, sizeof(config), 1, file);
if (ret != 1)
{
fprintf(stderr, "Failed to read the HWCONFIG entry in %s\n", HWCONFIG_DEVICE);
exit(EXIT_FAILURE);
}
if (strncmp(config.magic, HWCONFIG_MAGIC, strlen(HWCONFIG_MAGIC)) != 0)
{
fprintf(stderr, "Input file %s does not appear to contain a HWCONFIG entry\n", HWCONFIG_DEVICE);
exit(EXIT_FAILURE);
}
switch(config.pcb_id)
{
case E606A2_PCBID:
// 600x800
model = "cervantesTouch";
break;
case E60672_PCBID:
// 600x800 + frontlight
model = "cervantesTouchLight";
break;
case E60Q22_PCBID:
// 758x1024 + frontlight
model = "cervantes2013";
break;
case E60QH2_PCBID:
// 1072 x 1448 + frontlight
model = "cervantes3";
break;
case E60QP2_PCBID:
// 1072 x 1448 + frontlight + optimalight
model = "cervantes4";
break;
default:
model = "unkown";
break;
}
fprintf(stdout, "%s\n", model);
fclose(file);
return 0;
}
Not sure if we need (part of) that for FBInk
Closing in favor of #17
Since the device is based on Freescale I.Mx6 sololite processor is similar to kobos, but without hardfloat support (a-la kindle).
As kobos, cervantes devices rely on /dev/ntx_io to read chunks of HWCONFIG from the unpartitioned space at the top of internal storage.
There are mainly three kind of devices to support, which differ on resolution, frontlight and "optimalight". But as long as FBInk doesn't need to know if a device has light capabilities we can just read resolution.
framebuffer seems pretty standard too.
Need some help to figure out how to do device identification. Any hint?