{"id":19852716,"url":"https://github.com/shadowblip/ayn-platform","last_synced_at":"2025-05-02T00:31:30.911Z","repository":{"id":186595208,"uuid":"675361467","full_name":"ShadowBlip/ayn-platform","owner":"ShadowBlip","description":"Linux drivers for AYN x86 handhelds providing a hwmon interface for pwm fan control and temperature sensors, as well as RGB control.","archived":false,"fork":false,"pushed_at":"2025-03-15T02:47:00.000Z","size":52,"stargazers_count":6,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-06T20:22:46.202Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShadowBlip.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-06T16:57:34.000Z","updated_at":"2025-03-15T02:47:02.000Z","dependencies_parsed_at":"2025-03-15T03:25:03.923Z","dependency_job_id":"e7405c17-cfae-4dc6-b48d-8bc01130f426","html_url":"https://github.com/ShadowBlip/ayn-platform","commit_stats":null,"previous_names":["shadowblip/ayn-platform"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowBlip%2Fayn-platform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowBlip%2Fayn-platform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowBlip%2Fayn-platform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowBlip%2Fayn-platform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShadowBlip","download_url":"https://codeload.github.com/ShadowBlip/ayn-platform/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251966431,"owners_count":21672666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T14:04:06.739Z","updated_at":"2025-05-02T00:31:25.901Z","avatar_url":"https://github.com/ShadowBlip.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Platform driver for AYN x86 handhelds\n\nThis driver provides a hwmon interface for PWM control, as well as access \nto temperature sensors provided by the system EC\n\nSupported devices include:\n\n - AYN Loki Max\n\n## Build\nIf you only want to build and test the module (you need headers for your\nkernel):\n\n```shell\n$ git clone https://github.com/ShadowBlip/ayn-platform.git\n$ cd ayn-platform\n$ make\n```\n\nThen insert the module and check `sensors` and `dmesg` if appropriate:\n```shell\n# insmod ayn-platform.ko\n$ sensors\naynec-isa-0000\nAdapter: ISA adapter\nfan1:        3007 RPM\nBattery:      +29.0°C\nMotherboard:  +41.0°C\nCharger IC:   +38.0°C\nvCore:        +48.0°C\nCPU Core:     +48.0°C\n```\n\n## Install\n\nYou'll need appropriate headers for your kernel and `dkms` package from your\ndistribution.\n\n```shell\n$ git clone https://github.com/ShadowBlip/ayn-platform.git\n$ cd ayn-platform\n$ make\n# make dkms\n```\n\n## Usage\n\nInsert the module with `insmod`. Then look for a `hwmon` device with name\n`aynec`, i.e.:\n\n`$ cat /sys/class/hwmon/hwmon?/name`\n\n### Reading fan RPM\n\n`sensors` will show the fan RPM as read from the EC. You can also read the\nfile `fan1_input` to get the fan RPM.\n\n### Fan Control\n\n***Warning: controlling the fan without an accurate reading of the CPU, GPU,\nand Battery temperature can cause irreversible damage to the device. Use at\nyour own risk!***\n\n#### Automatic Control\nThis will use the BIOS default fan curve and is the default setting of the EC.\n\nTo enable automatic control of the fan (assuming `hwmon5` is our driver, look for\n`aynec` in the `name` file):\n\n`# echo 0 \u003e /sys/class/hwmon/hwmon5/pwm1_enable`\n\n#### Manual Control\nThis mode is useful to explicitly set a fan speed, or with the use of userspace\ntools that adjust fan speed using a custom fan curve defined in software.\n\nTo enable manual control of the fan (assuming `hwmon5` is our driver, look for\n`aynec` in the `name` file):\n\n`# echo 1 \u003e /sys/class/hwmon/hwmon5/pwm1_enable`\n\nThen input values in the range `[0-255]` to the pwm:\n\n`# echo 100 \u003e /sys/class/hwmon/hwmon5/pwm1`\n\n#### User Defined Control\nThis mode allows the user to override the default BIOS fan curve with a user\ndefined fan curve. There are 5 set point pairs for temperature and fan speed.\nThe temperature value is a cutoff for that set point, any CPU temperature\nbelow that point and above the lower set point will run at that set points\nfan speed. Temperature is in degrees Celsius.\n\nTo enable user defined control of the fan (assuming `hwmon5` is our driver,\nlook for `aynec` in the `name` file):\n\n`# echo 2 \u003e /sys/class/hwmon/hwmon5/pwm1_enable`\n\nSet an input value in the range `[0-255]` to the pwm:\n\n`# echo 100 \u003e /sys/class/hwmon/hwmon5/pwm1_auto_point1_pwm`\n\nSet an input value in the range `[0-100]` to the temp:\n\n`# echo 50 \u003e /sys/class/hwmon/hwmon5/pwm1_auto_point1_temp`\n\n### RGB Control\nRGB control is available using the character files found in the following location:\n`/sys/class/leds/multicolor:chassis/` . Writing to the files within this directory\ncan be done using the pattern `echo \u003cvalue\u003e | sudo tee \u003cpath\u003e`\n\n#### Mode Setting\nThere are two modes available, `Rainbow Breathing` is represented by the value `0`\nand `Manual` is represented by the value `1`. When in Rainbow Breathing mode,\nbrightness and color intensity changes are ignored. You must be in Manual mode to\nadjust the color or brightness of the LED's.\n\nTo change modes:\n`echo 1 | sudo tee /sys/class/leds/multicolor:chassis/device/led_mode`\n\n#### Identifying and Setting Color Values\nYou can read the `brightness`, `multi_index`, and `multi_intensity` from their\nrespective files in `/sys/class/leds/multicolor:chassis/` . Each do the following:\nbrightness: The current average luminosity of all three colors in the range `[0-255]`.\nSetting this to `0` will turn off the LED's while setting it to `255` represents the\nmaximum luminosity of the selected multi_intensity range.\nmulti_index: Displays the order of the colors when setting multi_intensity. Set to\n`red green blue`.\nmulti_intensity: The current intensity of each individual color [0-255] where 0 is off\nand 255 is most luminous. The value is dispalyed and set with three numbers separated\nby a single space. Each of these values is multiplied by the current brightness and\ndivided by the maximum brightness when setting the true value. A setting of `0 0 0` is\noff and `255 255 255` represents all colors at maximum intensity.\n\n## Changing Startup Defaults\nThe platform driver is fully exposed over systemd udev. This can be used to write udev rules that set attributes at startup.\n\n### Udev Attributes Tree\n#### LEDs\n```$ udevadm info --attribute-walk /sys/class/leds/multicolor:chassis\n\nlooking at device '/devices/platform/ayn-platform/leds/multicolor:chassis':\n    KERNEL==\"multicolor:chassis\"\n    SUBSYSTEM==\"leds\"\n    DRIVER==\"\"\n    ATTR{brightness}==\"0\"\n    ATTR{led_mode}==\"1\"\n    ATTR{max_brightness}==\"255\"\n    ATTR{multi_index}==\"red green blue\"\n    ATTR{multi_intensity}==\"0 0 0\"\n    ATTR{power/control}==\"auto\"\n    ATTR{power/runtime_active_time}==\"0\"\n    ATTR{power/runtime_status}==\"unsupported\"\n    ATTR{power/runtime_suspended_time}==\"0\"\n    ATTR{trigger}==\"[none] usb-gadget usb-host rc-feedback kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock ACAD-online \u003e\n\n  looking at parent device '/devices/platform/ayn-platform':\n    KERNELS==\"ayn-platform\"\n    SUBSYSTEMS==\"platform\"\n    DRIVERS==\"ayn-platform\"\n    ATTRS{driver_override}==\"(null)\"\n    ATTRS{power/control}==\"auto\"\n    ATTRS{power/runtime_active_time}==\"0\"\n    ATTRS{power/runtime_status}==\"unsupported\"\n    ATTRS{power/runtime_suspended_time}==\"0\"\n\n  looking at parent device '/devices/platform':\n    KERNELS==\"platform\"\n    SUBSYSTEMS==\"\"\n    DRIVERS==\"\"\n    ATTRS{power/control}==\"auto\"\n    ATTRS{power/runtime_active_time}==\"0\"\n    ATTRS{power/runtime_status}==\"unsupported\"\n    ATTRS{power/runtime_suspended_time}==\"0\"\n\n```\n\n#### hwmon\n```\n$ udevadm info  --attribute-walk /sys/class/hwmon/hwmon6\n\n  looking at device '/devices/platform/ayn-platform/hwmon/hwmon6':\n    KERNEL==\"hwmon6\"\n    SUBSYSTEM==\"hwmon\"\n    DRIVER==\"\"\n    ATTR{fan1_input}==\"3032\"\n    ATTR{name}==\"aynec\"\n    ATTR{power/control}==\"auto\"\n    ATTR{power/runtime_active_time}==\"0\"\n    ATTR{power/runtime_status}==\"unsupported\"\n    ATTR{power/runtime_suspended_time}==\"0\"\n    ATTR{pwm1}==\"64\"\n    ATTR{pwm1_auto_point1_pwm}==\"0\"\n    ATTR{pwm1_auto_point1_temp}==\"0\"\n    ATTR{pwm1_auto_point2_pwm}==\"0\"\n    ATTR{pwm1_auto_point2_temp}==\"0\"\n    ATTR{pwm1_auto_point3_pwm}==\"0\"\n    ATTR{pwm1_auto_point3_temp}==\"0\"\n    ATTR{pwm1_auto_point4_pwm}==\"0\"\n    ATTR{pwm1_auto_point4_temp}==\"0\"\n    ATTR{pwm1_auto_point5_pwm}==\"0\"\n    ATTR{pwm1_auto_point5_temp}==\"0\"\n    ATTR{pwm1_enable}==\"0\"\n    ATTR{temp1_input}==\"35000\"\n    ATTR{temp1_label}==\"Battery\"\n    ATTR{temp2_input}==\"42000\"\n    ATTR{temp2_label}==\"Motherboard\"\n    ATTR{temp3_input}==\"53000\"\n    ATTR{temp3_label}==\"Charger IC\"\n    ATTR{temp4_input}==\"48000\"\n    ATTR{temp4_label}==\"vCore\"\n    ATTR{temp5_input}==\"47000\"\n    ATTR{temp5_label}==\"CPU Core\"\n\n  looking at parent device '/devices/platform/ayn-platform':\n    KERNELS==\"ayn-platform\"\n    SUBSYSTEMS==\"platform\"\n    DRIVERS==\"ayn-platform\"\n    ATTRS{driver_override}==\"(null)\"\n    ATTRS{power/control}==\"auto\"\n    ATTRS{power/runtime_active_time}==\"0\"\n    ATTRS{power/runtime_status}==\"unsupported\"\n    ATTRS{power/runtime_suspended_time}==\"0\"\n\n  looking at parent device '/devices/platform':\n    KERNELS==\"platform\"\n    SUBSYSTEMS==\"\"\n    DRIVERS==\"\"\n    ATTRS{power/control}==\"auto\"\n    ATTRS{power/runtime_active_time}==\"0\"\n    ATTRS{power/runtime_status}==\"unsupported\"\n    ATTRS{power/runtime_suspended_time}==\"0\"\n\n```\n\n### Creating a rule\nYou can store a udev rule as `/etc/udev/rules.d/##-rule_name.rules`\n\nAll rules will start like this:\n`ACTION==\"add|change\", KERNEL==\"multicolor:chassis\", SUBSYSTEM==\"leds\"`\n\nTo define a default, add the attribute in the format `ATTR{name}=value`\n\nLEDs valid attributes are:\n```\nATTR{brightness}==\"[0-255]\"\nATTR{led_mode}==\"[0-1]\"\nATTR{multi_intensity}==\"[0-255] [0-255] [0-255]\"\n```\n\nhwmon valid attributes are:\n```\nATTR{pwm1}==\"[0-100]\"\nATTR{pwm1_auto_point1_pwm}==\"[0-255]\"\nATTR{pwm1_auto_point1_temp}==\"[0-100]\"\nATTR{pwm1_auto_point2_pwm}==\"[0-255]\"\nATTR{pwm1_auto_point2_temp}==\"[0-100]\"\nATTR{pwm1_auto_point3_pwm}==\"[0-255]\"\nATTR{pwm1_auto_point3_temp}==\"[0-100]\"\nATTR{pwm1_auto_point4_pwm}==\"[0-255]\"\nATTR{pwm1_auto_point4_temp}==\"[0-100]\"\nATTR{pwm1_auto_point5_pwm}==\"[0-255]\"\nATTR{pwm1_auto_point5_temp}==\"[0-100]\"\nATTR{pwm1_enable}==\"[0-2]\"\n```\n\n\nAs en example, to set the LED's to breath:\n`\nACTION==\"add|change\", KERNEL==\"multicolor:chassis\", SUBSYSTEM==\"leds\", ATTR{led_mode}==\"0\"\n`\n\nto create the rule in one line:\n```shell\n$ echo 'ACTION==\"add|change\", KERNEL==\"multicolor:chassis\", SUBSYSTEM==\"leds\", ATTR{led_mode}==\"0\"' | sudo tee /etc/udev/rules.d/99-led_startup.rules\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshadowblip%2Fayn-platform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshadowblip%2Fayn-platform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshadowblip%2Fayn-platform/lists"}