<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Dec 21, 2016 at 7:42 AM Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Dec 21, 2016 at 4:19 AM, Ville Syrjälä<br class="gmail_msg">
<<a href="mailto:ville.syrjala@linux.intel.com" class="gmail_msg" target="_blank">ville.syrjala@linux.intel.com</a>> wrote:<br class="gmail_msg">
> On Wed, Dec 21, 2016 at 10:15:15AM +0100, Daniel Vetter wrote:<br class="gmail_msg">
>> On Tue, Dec 20, 2016 at 07:46:12PM -0500, Rob Clark wrote:<br class="gmail_msg">
>> > On Tue, Dec 20, 2016 at 7:12 PM, Kristian H. Kristensen<br class="gmail_msg">
>> > <<a href="mailto:hoegsberg@gmail.com" class="gmail_msg" target="_blank">hoegsberg@gmail.com</a>> wrote:<br class="gmail_msg">
>> > > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h<br class="gmail_msg">
>> > > index ce7efe2..cea3de3 100644<br class="gmail_msg">
>> > > --- a/include/uapi/drm/drm_mode.h<br class="gmail_msg">
>> > > +++ b/include/uapi/drm/drm_mode.h<br class="gmail_msg">
>> > > @@ -209,6 +209,33 @@ struct drm_mode_get_plane {<br class="gmail_msg">
>> > > __u64 format_type_ptr;<br class="gmail_msg">
>> > > };<br class="gmail_msg">
>> > ><br class="gmail_msg">
>> > > +struct drm_format_modifier {<br class="gmail_msg">
>> > > + /* Bitmask of formats in get_plane format list this info<br class="gmail_msg">
>> > > + * applies to. */<br class="gmail_msg">
>> > > + uint64_t formats;<br class="gmail_msg">
>> ><br class="gmail_msg">
>> > Hmm, this seems a bit clunky/brittle when you have a lot of supported<br class="gmail_msg">
>> > formats (esp. if format order changes or new formats are not added at<br class="gmail_msg">
>> > end). I guess fine when you support a four or five different formats,<br class="gmail_msg">
>> > but I think you'll start to hate maintaining those tables on hw that<br class="gmail_msg">
>> > supports more.<br class="gmail_msg">
>> ><br class="gmail_msg">
>> > Also I guess it limits you to modifiers only with the first 64<br class="gmail_msg">
>> > formats.. maybe not a problem right away, but a quick look and drm/msm<br class="gmail_msg">
>> > is already at 23 formats (and there are probably some more it could<br class="gmail_msg">
>> > do.. without even starting to get into "exotic" float/etc formats and<br class="gmail_msg">
>> > whatever else might come in the future.<br class="gmail_msg">
>><br class="gmail_msg">
>> Hm, I'd have said with max 23 currently used 64 is good enough.<br class="gmail_msg">
>> ><br class="gmail_msg">
>> > Not that I really have a better idea.. maybe just instead of<br class="gmail_msg">
>> > getplane2 we just add a querymodifiers ioctl (ie. fourcc in, list of<br class="gmail_msg">
>> > modifiers out), with the idea that userspace probably knows what<br class="gmail_msg">
>> > format/fourcc it wants to use, and only just cares about modifiers for<br class="gmail_msg">
>> > that particular fourcc..<br class="gmail_msg">
>><br class="gmail_msg">
>> Could we do a table of tables instead, at least internally? So<br class="gmail_msg">
>><br class="gmail_msg">
>> struct drm_format_support {<br class="gmail_msg">
>> u64 modifiers;<br class="gmail_msg">
>> u32 *formats;<br class="gmail_msg">
>> };<br class="gmail_msg">
>><br class="gmail_msg">
>> And then supply an array of those? Maybe with some magic to convert it in<br class="gmail_msg">
>> the ioctl since the proposed ioctl struct is easier to transport to<br class="gmail_msg">
>> userspace. Could also switch over to terminating arrays with a final 0<br class="gmail_msg">
>> element (like with pci tables and everything else used in the kernel) to<br class="gmail_msg">
>> get rid of all those silly ARRAY_SIZE lines. Totalling up:<br class="gmail_msg">
>><br class="gmail_msg">
>> u32 format_list_untiled[] = { RGBX8888, RGBA8888, 0 };<br class="gmail_msg">
>> u32 format_list_tiled[] = { RGBX8888, 0 };<br class="gmail_msg">
>><br class="gmail_msg">
>> struct drm_format_support formats[] = {<br class="gmail_msg">
>> { MODE_NODE, format_untiled },<br class="gmail_msg">
>> { MODE_TILED, format_tiled },<br class="gmail_msg">
>> { 0, NULL }<br class="gmail_msg">
>> };<br class="gmail_msg">
>><br class="gmail_msg">
>> Not sure that's any better really.<br class="gmail_msg">
><br class="gmail_msg">
> I think what we might want is:<br class="gmail_msg">
><br class="gmail_msg">
> u32 formats[]<br class="gmail_msg">
> u64 modifiers[]<br class="gmail_msg">
> bool (*format_mod_supported)(u32 format, u64 modifier);<br class="gmail_msg">
><br class="gmail_msg">
> The driver provides those, and the core will then just go through the<br class="gmail_msg">
> combinations and build up the masks. We could then also reuse that stuff<br class="gmail_msg">
> for addfb2 so that the core will call that same hook to check whether<br class="gmail_msg">
> the format+modifier is supported. That way the driver .fb_create() will<br class="gmail_msg">
> never see any unsupported combinations and we avoid having to duplicate<br class="gmail_msg">
> any logic there to see which hardware supports which formats.<br class="gmail_msg">
><br class="gmail_msg">
<br class="gmail_msg">
I do like this for internal API better, rather than driver building up<br class="gmail_msg">
tables itself.<br class="gmail_msg"></blockquote><div><br></div><div>Yeah, I like Ville's suggestion too, I'll give it a try.</div><div><br></div><div>Kristian</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
BR,<br class="gmail_msg">
-R<br class="gmail_msg">
</blockquote></div></div>