Hacker News new | past | comments | ask | show | jobs | submit login
Please think architecture (2007) (freebsd.org)
115 points by cnst on Oct 26, 2019 | hide | past | favorite | 27 comments



Who's right?

Trees couple hierarchy into information, and there lies the problem. Same thing could be modelled as a table, and allow both views:

    root             hw
    vendor_submodule acpi
    vendor           fujitsu
    vendor_feature   lcd_brightness
    submodule        backlight
    feature          brightness
    value            4
Architecture ain't easy...


Why is it necessary to include vendor information in a setting like this?

The value, which represents the user’s desired brightness setting, could be an opaque number and the device driver could be responsible for translating that into whatever is needed to make the display behave.


The freebsd laptop I'm writing this on has:

    $ sysctl -a | grep brightness
    hw.acpi.video.lcd0.brightness: 50
    compat.linuxkpi.i915_invert_brightness: 0
So if you want to write a script that works both, you need to put fujitsu-specific knowledge in your script. Vs. alternatively, an interface that works everywhere.

(Incidentally I think this sysctl doesn't do much and I instead use a utility called intel_backlight(1) from ports.)


I like how the abstraction point is at LCD. It's abstracting a specific hardware type, not a hardware feature.


And this is why we still have lots of applications where it's difficult or impossible to bind certain inputs. Someone had a mental image of a typical keyboard, then a typical mouse, and that's what we're stuck with. It's not like the sixth thumb button in my mouse is very different from the Print Screen key on my keyboard or the X button in my wireless gamepad. And that's why tools that make your input device X emulate a different type of input device Y are common (but annoying to set up since the setup is going to be application specific).

I'm not aware of a single API that offers a sufficiently device-agnostic view of inputs that you can write the application code once and then let the user bind anything they can connect to their computer somehow.

The USB spec actually comes close since it starts at the actual hardware inputs (toggle switch, button, relative motion, absolute motion, etc.) and their range, and then offers hints about their intended usage or meaning. It's the layers above that suck.


    I'm not aware of a single API that offers a sufficiently device-agnostic
It looks like the goal of `Steam Controller Configurator` project by steam is doing this. (I think this should be done by a systeam level app instead.. but no one is doing this)

The configurator api steam provides actually abstract the `real input device layout` away from the `the action user want to do`, which allows games to support `future` input device.

The game itself longer needs to handle every input device layout one by one. Instead, it will have a general way to handle unknown device.

The Configurator ask the game `which action you can do?` and the game response the actions (like jump, walk, sprint ...etc) to the api, and let the api bind the action to whatever key properly on the device(x on xbox one, square on ps4...etc).


I haven't used that thing but if it is as you say, it sounds backwards and very rigid, and probably only good for games (with assumptions about how the application might want to use inputs).

I don't think system level APIs should ask applications anything at all.

Applications should be able to ask for inputs instead. Which is the status quo, with the caveat that there's no unified "input" API, instead there's a bunch of different APIs for keyboard, mouse, joystick, xinput gamepad, text input, midi, other kinds of input (lucky if you can find an existing API for them...). Some of these APIs multiplex a few different types of inputs, but still provide them as distinct types of events that need to be handled separately by each application.


Then your program failed completely on the input device currently does not exist.

How do your program know there is a controller use [w] as confirm instead of [o] when the controller does not even exist when you are writing the program?

Although the new controller can just send [w] as [o], you will now have another problem that ui always ask you to press [o] when there is only [w] on the controller.

Fix this problem is the sole purpose of that configurator. Don't choose the layout, just let user/system choose them. Although you could still define some preset for known device.


What laptop are you using for freebsd? Also what desktop environment? I've tried forever to get a BSD laptop setup working.


Lenovo X1 Carbon 6th gen.

I don't use a big "desktop" like gnome, just a normal/light X setup resembling the 1990s. Lately it's dwm. Sometimes I do others.

Some things that might save you some time in loader.conf:

   acpi_video_load="YES"
   acpi_ibm_load="YES"
Also, had to set ACPI to "Linux" mode in bios. After that plus the two lines above, suspend works.

Also, xf86-video-intel from ports.

Wifi is slow but I'm ok with that.

Long ago I used OpenBSD on a laptop, and in my experience, with thinkpads, it has a bit more of a "just works" feel than FreeBSD for hardware support. But I'm on freebsd because of a few things that don't work on openbsd these days [like linux binary emulation].


For what value of working? I have a Lenovo X220 that works mostly fine. Sleeps on lid close, WiFi, trackpad. I don’t use it often, I keep it as a disposable backup, but it works.


I'm not aware of any sysctl values that can be accessed from two separate paths.


IIRC there are many values like that. There are "subsystem" or "driver" directories that don't even look like symlinks but lead into other subtrees. You can use such inter-subsystem links to create infinitely long sysctl paths.


So what happens if you plug your laptop into a docking station that has its own backlight? What if a new laptop comes out that has multiple backlights (perhaps of different colors)? In both of these circumstances the assumption that there is one backlight is faulty and not future-proofed.

Not to mention that the units don't carry over from one vendor to another.


> Not to mention that the units don't carry over from one vendor to another.

Who cares about the units? When was the last time you used a vendor-provided utility to configure a Network Interface Card, instead of just using ifconfig (if you're on BSD)? On OpenBSD, there's also bioctl for RAID management, too — https://en.wikipedia.org/wiki/Bioctl. And sysctl hw.sensors for temperature sensors and more.

How's brightness any different? It's a percentage value from 0 to 100%. Would the user really care how many internal settings a given machine has, and that 100% is really just 16 internally?


Sure they do! When I press "brightness up" shortcut on my keyboard, I want my laptop to brighten by 1 physical step, or by 2%, whatever is bigger.

Having to press the key multiple times just to get any effect is super frustrating.


I think those shortcuts are often handled by the driver itself, so, it'll already know the required stepping. Another option could be to provide such stepping explicitly as another sysctl.

Otherwise, realistically, the keyboard shortcut stepping could simply be assumed to have only 16 variations in the first place, even if you're still using a percentage point through the interface.


You expose a second, more specific, value. Then provide a useful fallback for when you set the old generic value. If you have a multicolored backlight, then a user of the old abstraction just wants white. If there's multiple backlights, you could just dim them all.

This is what an abstraction is. The abstraction doesn't need to cover all possible cases in the future. You just have to pick what that abstraction will mean for your new thing when you have it.


His next post on that list, on a different subject, is also pretty entertaining:

https://lists.freebsd.org/pipermail/freebsd-arch/2007-August...


Has this changed since 2007? (don't have any freebsd available to check)


Guess not: https://www.freebsd.org/cgi/man.cgi?query=acpi_fujitsu&sekti...

> hw.acpi.fujitsu.lcd_brightness

From man acpi_fujitsu on an actual system:

  SYSCTL VARIABLES
     These sysctls are currently implemented:

     hw.acpi.fujitsu.lcd_brightness
             Makes the LCD backlight brighter or dimmer.

     hw.acpi.fujitsu.pointer_enable
             Enables or disables the internal mouse pointer.

     hw.acpi.fujitsu.volume
             Controls the speaker volume.

     hw.acpi.fujitsu.mute
             Mutes the speakers.


Looks like it's still the same in 2019, based on documentation:

* http://bxr.su/f/s?q=lcd_brightness

* http://mdoc.su/f/acpi_fujitsu.4

Fun fact: PHK posted the above "architecture" rant only a couple of months prior to vetoing the import of OpenBSD's hw.sensors framework into FreeBSD (October 2007). Isn't that ironic?

FreeBSD still doesn't have a sensors framework to this day. Meanwhile, NetBSD will be celebrating 20 years of envsys(4) in a few months. And the count of sensor drivers in OpenBSD is currently at about 111 individual device drivers (yes, over a hundred different drivers — everyone gets a sensor in OpenBSD).


The "generic" one is necessarily a UI to the device, not the actual device, because there's always some kind of special casing or variation in an abstract property like that. Having the UI is of benefit when it serves as a building block, but not if it cuts off customization for some task.


Negative. Backlighting is vendor specific. Different implementations offer different configurations.

I do agree you probably want a base object for inheritance, exposing a common interface wouldn't be a good idea.

No matter what, you need to implement your abstraction. You're always going to end up with a list of vendor specific implementations.


> Negative. Backlighting is vendor specific. Different implementations offer different configurations.

Are you joking? For an analogy, do any NIC vendors even provide their own tools for configuring their Ethernet cards? And even if some do, how many people actually bother to use those, instead of OS-specific utilities like ifconfig? How's backlighting any different here?


The networking analogy would be things like DPDK, where yes, you do need to know what the hardware is doing, and yes, there's vendor-specific support. The answer to "how many people bother" would be "as many as have a damn good reason to do so." http://doc.dpdk.org/guides/nics/overview.html shows the non-homogeneity of NIC feature support across vendors; if you don't care about this stuff, there's no reason to know it, but if you do, it's make or break.


Sure, that's a lot of variation. Sure, some of these features are essential for certain applications, like checksum offload etc. However, most of these features are still uniform enough that a whole bunch of them are supported by standard drivers included with all BSD operating systems, and configurable with the standard ifconfig of each BSD, too:

http://mdoc.su/-/ifconfig.8

The fact that you even have a whole table with these features shows that these features are not that difficult to categorise and unbrand to be general enough to have OS-defined behaviours and configurations for.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: