Skip to content

Add video-codecs meson option to limit the supported codecs - #6

Merged
sofus13 merged 6 commits into
mainfrom
codec-selection
Oct 28, 2026
Merged

sofus13 merged 6 commits into
mainfrom
codec-selection

Conversation

@jannau

@jannau jannau commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

For legal reasons distribution might not be able to ship support for all codecs. Allow them to limit the support in the firmware. User will be able to install firmware with full support to /lib/firmware/updates/.

Goes together with AsahiLinux/linux@0f086c1

Also embed basic firmware information in the binary. The Makefile build does not support this so drop it rather than adding support.

This is based on the same option in mesa's meson.build / meson.options and defaults to "all_free" which is av1 and vp9.


Please check all boxes that apply:

  • This code was developed in accordance with the Asahi Linux Copyright Policy
  • I have not used generative AI/LLMs to develop this code, in accordance with the Asahi Linux LLM Policy
  • I have certified the above by adding a Signed-off-by: trailer to every commit

All boxes must be checked before your pull request can be reviewed.

@jannau

jannau commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Option and meson implementation is based on the option with the same name in mesa

Comment thread meson.build Resolved
Comment thread meson.build Resolved
@jannau
jannau force-pushed the codec-selection branch 3 times, most recently from 8be883f to 6b3c125 Compare October 21, 2026 21:56
Comment thread avd-cm3.ld
@@ -0,0 +1,12 @@
SECTIONS {
. = 0x00000000;
.vectors : { *(.vectors) }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put config/license after vectors? vectors should use at most 0x400 bytes, 240 interrupts + 16 entries (sp, nmi and friends). I kinda wanna reserve at least 256 bytes for config

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. It's a little tight with the text. only 12 byte remaining from 0x280 to 0x300

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like

    .vectors : { *(.vectors) }
    . = 0x00000400;
    .config : { *(.config)   }
    . = 0x00000500;
    .license : { *(.license) } =0x00
    .text    : { *(.text*)   }

Each version of hardware has gotten more interrupts, this should work as long as its an Cortex-m3

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misread your comment. that layout is fine by me. I'll update the PR

Comment thread meson.build
]

conf_data = configuration_data()
conf_data.set_quoted('AVD_FW_VERSION', meson.project_version())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a downside to using git tags instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The are not available in tarballs downloaded from git tags. Switched anyway and using https://mesonbuild.com/Creating-releases.html#cement-a-version-obtained-from-vcs which means we have to use github releases and upload our own tarballs generated by meson dist

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. I should have made it clear that it was more of a question. I was not aware of the tarballs missing the tags.
Manual tarballs seem kinda annoying and i think it would break how distros package it. I dont think its worth the tradeoff

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a tradeoff. The hardcoded version in meson build is also something which can be easily forgotten and then build will report a different version than the tag.
I plan to write a CI workflow which produces dist tarballs. Still requires to download the tag's artifacts and upload them to the release. There doesn't seem to be a way tell github that (I haven't searched for it either though).

I'll split this off to a separate PR

Comment thread src/avd.h Resolved
@jannau
jannau force-pushed the codec-selection branch 2 times, most recently from fc7755c to 0b166e1 Compare October 22, 2026 22:41
Otherwise the targets won't be rebuilt on avd-cm3.ld changes.

Fixes: 1bc7a80 ("build: Add meson build")
Signed-off-by: Janne Grunau <j@jannau.net>
Those includes define data and must be included only once. Allows to use
avd.h to define values and data types as expected from a header.

Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Janne Grunau <j@jannau.net>
The bitmask of enabled codecs is embedded in the 256-byte large config
struct at offset 0x400 of the firmware binary.
This uses meson's configuration_data / configure_file so remove the
Makefile as it is no longer supported.

Signed-off-by: Janne Grunau <j@jannau.net>
@jannau
jannau force-pushed the codec-selection branch 2 times, most recently from bf13855 to d3fea30 Compare October 24, 2026 20:45
@jannau
jannau added this pull request to stack #8 October 24, 2026 21:05
Comment thread meson.options
option(
'video-codecs',
type : 'array',
value : ['all_free'],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would either all or none, be a better default? Using all would be to mirror the fw we would submit to linux-firmware while not having a default would be to avoid confusion

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is uses the same default as mesa and is based on the principle of least bad surprise for distro packagers. I'd argue the default matters even less since linux firmware will distribute binaries. To avoid confusion the change adding the firmware binaries to linux-firmware should mention that. It might make sense to to include both all and all_free builds in linux-firmware so distros can chose in their packaging.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For linux-firmware we would still need to choose a default, which would presumably be the all build. In my head it was better if the distro packagers already knew that our fw would need special handling. Hence the default of all (convenient and no breaking change) or none (needs an active choice, impossible to ignore).

It does not really matter. The all_free default does not hurt anyone and is easy spot so im ok with it, thanks

@sofus13

sofus13 commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

The last commit still refers to the old layout. Please also enable all codecs in the ci

Embed the project name, version and copyright information before the
firmware code after the embedded config struct.

Signed-off-by: Janne Grunau <j@jannau.net>
@jannau
jannau force-pushed the codec-selection branch 5 times, most recently from f7620b9 to b94106b Compare October 25, 2026 13:41
…ilds

Replaces the previous ci workflow.

Signed-off-by: Janne Grunau <j@jannau.net>
@sofus13
sofus13 merged commit 4488613 into main Oct 28, 2026
3 checks passed
@jannau
jannau deleted the codec-selection branch October 31, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants