Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose device name and bus info #60

Merged
merged 4 commits into from
Apr 11, 2023
Merged

Conversation

bazile-clyde
Copy link
Contributor

From the kernel docs here

[card] Name of the device, a NUL-terminated UTF-8 string. For example: “Yoyodyne TV/FM”. One driver may support different brands or models of video hardware. This information is intended for users, for example in a menu of available devices. Since multiple TV cards of the same brand may be installed which are supported by the same driver, this name should be combined with the character device file name (e. g. /dev/video2) or the bus_info string to avoid ambiguities.

[bus_info] Location of the device in the system, a NUL-terminated ASCII string. For example: “PCI:0000:05:06.0”. This information is intended for users, to distinguish multiple identical devices. If no such information is available the field must simply count the devices controlled by the driver (“platform:vivi-000”). The bus_info must start with “PCI:” for PCI boards, “PCIe:” for PCI Express boards, “usb-” for USB devices, “I2C:” for i2c devices, “ISA:” for ISA devices, “parport” for parallel port devices and “platform:” for platform devices.

webcam.go Outdated
@@ -54,7 +54,7 @@ func Open(path string) (*Webcam, error) {
}

w := new(Webcam)
w.fd = uintptr(fd)
w.fd = fd
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: this already done above.

}

// GetBusInfo returns the location of the device in the system
func (w *Webcam) GetBusInfo() (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this have a better name in this case? Like path or something? the syscall side is fine but this file is an opportunity for cleaner names

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. See the comment attached to this PR. In short, we use GetName to get the human-readable name. For conflicts the kernel recommends you append either the bus info or the path. The bus info isn't exposed so I exposed it here. The path isn't in the v4l2_capability struct so we can't "expose" it. We already know what it is because we've used it (or a symbolic link to it) to open the device. How this will ultimately be displayed by the user is up to the caller. They'll most likely do one of the following

  • Yoyodyne TV/FM if no conflicts
  • Yoyodyne TV/FM (PCI:0000:05:06.0) in the case of conflicts OR
  • Yoyodyne TV/FM (/dev/video2) in the case of conflicts

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it. Makes sense.

v4l2.go Outdated Show resolved Hide resolved
v4l2.go Outdated Show resolved Hide resolved
@bazile-clyde bazile-clyde requested a review from edaniels April 10, 2023 18:57
bazile-clyde and others added 2 commits April 10, 2023 18:31
Co-authored-by: Eric Daniels <eric@erdaniels.com>
Co-authored-by: Eric Daniels <eric@erdaniels.com>
@edaniels
Copy link
Collaborator

LGTM

@edaniels edaniels merged commit b5cdb70 into blackjack:master Apr 11, 2023
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