aleksb / yogabook-c930-linux-eink-driver

An attempt to reverse-engineer the YogaBook C930 driver and implement one for Linux
GNU General Public License v2.0
61 stars 8 forks source link

Lenovo Open Source Code #2

Open KoviRobi opened 5 years ago

KoviRobi commented 5 years ago

Hi,

First of all, thank you very much for your work! I was just wondering if you have seen https://pcsupport.lenovo.com/us/en/products/tablets/yoga-series/yoga-book-c930/downloads/DS503569 ? It seems like the e-reader component of the interface, which is as far as I can work it out, a Windows program (like the other non-keyboard stuff not available in the BIOS, e.g. the top bar to select programs, input tablet, note-taking mode, settings). I haven't had a proper look at it, but hopefully I can start doing that, and possibly port it. I'd love to mess around with the font settings in the e-reader app anyway, because I think I could get them to be crisper. And make notes on PDFs, have a game-controller style input, change keyboard layout (not sure that code is in here), and other stuff that would be cool.

Also, this isn't so much of an issue, but I didn't know where else to put the conversation on GitHub.

arrowmancer commented 4 years ago

Hi KoviRobi. Have you made any progress on this end since? I'd love to look into this as well.

KoviRobi commented 4 years ago

No, unfortunately I have been distracted by much else, I'll see if I have some time soon but do let me know if you make any progress :)

aleksb commented 4 years ago

I don't have the time to work on this, but maybe I can contribute some ideas regarding reverse-engineering etc.

csdvrx commented 3 years ago

Unrelated, but maybe you'll now.

@aleksb during your reverse, have you noticed how the Windows executables work?

From what I've seen, einksettings.exe maintains a file lock on the custom picture selected to use as background ; restarting the EinkSvr service or killing the process releases the lock, but then, updates to the picture that happened between the stop and the restart aren't processed.

On Windows, since the calendar function doesn't work, the idea is to create a suspend picture with practical data (ex: calendar, disk free...) and automatically feed it to einksettings so that it's refreshed before a suspend.

I thought about simply killing einksettings and updating the file, but that isn't enough.

Given the Settings.xml file where the custom image is only indexed with a number, and not a full path, I think einksettings.exe "caches" this image somewhere.

aleksb commented 3 years ago

Sorry, I never played around with the Windows stuff much. Feel free to add anything related to this repo even if it's Windows based.

KoviRobi commented 3 years ago

Well I've had a little time to start looking at things, in the Lenovo open source archive, from inc/tconcmd.h

/* License: COPYING.GPLv3 */
/* Copyright 2019 - present Lenovo */
#pragma once

// ITE TCON Error Code
const DWORD ITETCON_EC_SUCCESS = 0;
const DWORD ITETCON_EC_FAILED = -1;

#define SCSI_OPCODE_INQUIRY     0x12
#define SCSI_OPCODE_ITECUSTOM   0xFE

//IT8951 USB Op Code - Fill this code to CDB[6]
#define IT8951_USB_OP_GET_SYS      0x80
#define IT8951_USB_OP_READ_MEM     0x81
#define IT8951_USB_OP_WRITE_MEM    0x82
#define IT8951_USB_OP_READ_REG     0x83
#define IT8951_USB_OP_WRITE_REG    0x84

#define IT8951_USB_OP_DPY_AREA     0x94

#define IT8951_USB_OP_USB_SPI_ERASE 0x96 //Eric Added
#define IT8951_USB_OP_USB_SPI_READ  0x97
#define IT8951_USB_OP_USB_SPI_WRITE 0x98

#define IT8951_USB_OP_LD_IMG_AREA  0xA2
#define IT8951_USB_OP_PMIC_CTRL    0xA3
#define IT8951_USB_OP_IMG_CPY      0xA4 //Not used in Current Version(IT8961 Samp only)
#define IT8951_USB_OP_FSET_TEMP    0xA4
#define IT8951_USB_OP_FAST_WRITE_MEM 0xA5
#define IT8951_USB_OP_SCENARIO     0xA6
#define IT8951_USB_OP_LD_IMG_AREA2 0xA8
#define IT8951_USB_OP_SET_WAVEFORM 0xA9
#define IT8951_USB_OP_SET_HANDWR_REGION  0xAC
#define IT8951_USB_OP_SET_HANDWR_WIDTH   0xAE
#define IT8951_USB_OP_SET_TP_AREA    0xAF

#define IT8951_USB_OP_GET_DPY_STATUS 0xB1
#define IT8951_USB_OP_SET_LD_IMG_AREA2  0xB2
// zhuhl5
#define IT8951_USB_OP_DYNAMICSETTING 0xB3

This seems to be the USB level stuff between the host and the IT8951 controller, which I believe drives the E-ink signals (there is probably also a TPS65185 behind that somewhere to do the voltage levels, I don't think it matters to us, just from my playing around with e-ink before).

Some of these values are ones you use @aleksb , e.g. 0x94.

There also appears to be some other components in the included open source release, that communicate using IPC (see EInkIteAPI/dllmain.cpp and EinkIteAPI/EiAppCenter.{h,cpp}). I haven't figured this out properly, I'll have a play around to see if I can capture the pipe in Windows

(Note file encoding seems to be GB18030)

// 初始化执行体
ULONG CEiAppCenter::Initialize(TRSP_SYSTEM_INFO_DATA& rSystemInfoData)
{
    ULONG luResult;

    //生成管道名称
    wchar_t lszTempBuffer[MAX_PATH] = { 0 };
    GetGUIDString(lszTempBuffer, MAX_PATH);
    swprintf_s(mdRegAppInfo.mszAppFilePath, MAX_PATH, L"\\\\.\\pipe\\%s.eink", lszTempBuffer);
ghost commented 3 years ago

Looking forward to seeing what you're able to do with this, since as of the latest requirements document from Microsoft, this laptop will NOT be supported in Windows 11 (the CPU is a 7th-gen i5 CPU, and the minimum required is 8th-gen).