libcamera: Use 'struct' for structure types

Add back the 'struct' keyword for structure types.
C++ allows omitting the 'struct' keywork. Add it back to make clear
we're dealing with structures and not class types.

While at there re-sort fields of media_v2_* type in populate() function
to reflect the declaration order in the kernel headers.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Jacopo Mondi 2019-01-02 12:56:48 +01:00
parent 4e5a93da83
commit 171f4c0a0d

View file

@ -206,9 +206,9 @@ int MediaDevice::populate()
{ {
struct media_v2_topology topology = { }; struct media_v2_topology topology = { };
struct media_v2_entity *ents = nullptr; struct media_v2_entity *ents = nullptr;
struct media_v2_interface *interfaces = nullptr;
struct media_v2_link *links = nullptr; struct media_v2_link *links = nullptr;
struct media_v2_pad *pads = nullptr; struct media_v2_pad *pads = nullptr;
struct media_v2_interface *interfaces = nullptr;
__u64 version = -1; __u64 version = -1;
int ret; int ret;
@ -220,9 +220,9 @@ int MediaDevice::populate()
while (true) { while (true) {
topology.topology_version = 0; topology.topology_version = 0;
topology.ptr_entities = reinterpret_cast<__u64>(ents); topology.ptr_entities = reinterpret_cast<__u64>(ents);
topology.ptr_interfaces = reinterpret_cast<__u64>(interfaces);
topology.ptr_links = reinterpret_cast<__u64>(links); topology.ptr_links = reinterpret_cast<__u64>(links);
topology.ptr_pads = reinterpret_cast<__u64>(pads); topology.ptr_pads = reinterpret_cast<__u64>(pads);
topology.ptr_interfaces = reinterpret_cast<__u64>(interfaces);
ret = ioctl(fd_, MEDIA_IOC_G_TOPOLOGY, &topology); ret = ioctl(fd_, MEDIA_IOC_G_TOPOLOGY, &topology);
if (ret < 0) { if (ret < 0) {
@ -235,15 +235,15 @@ int MediaDevice::populate()
if (version == topology.topology_version) if (version == topology.topology_version)
break; break;
delete[] links;
delete[] ents; delete[] ents;
delete[] pads;
delete[] interfaces; delete[] interfaces;
delete[] pads;
delete[] links;
ents = new media_v2_entity[topology.num_entities](); ents = new struct media_v2_entity[topology.num_entities]();
links = new media_v2_link[topology.num_links](); interfaces = new struct media_v2_interface[topology.num_interfaces]();
pads = new media_v2_pad[topology.num_pads](); links = new struct media_v2_link[topology.num_links]();
interfaces = new media_v2_interface[topology.num_interfaces](); pads = new struct media_v2_pad[topology.num_pads]();
version = topology.topology_version; version = topology.topology_version;
} }
@ -254,10 +254,10 @@ int MediaDevice::populate()
populateLinks(topology)) populateLinks(topology))
valid_ = true; valid_ = true;
delete[] links;
delete[] ents; delete[] ents;
delete[] pads;
delete[] interfaces; delete[] interfaces;
delete[] pads;
delete[] links;
if (!valid_) { if (!valid_) {
clear(); clear();
@ -402,7 +402,7 @@ struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topo
return nullptr; return nullptr;
struct media_v2_interface *ifaces = reinterpret_cast<struct media_v2_interface *> struct media_v2_interface *ifaces = reinterpret_cast<struct media_v2_interface *>
(topology.ptr_interfaces); (topology.ptr_interfaces);
for (i = 0; i < topology.num_interfaces; ++i) { for (i = 0; i < topology.num_interfaces; ++i) {
if (ifaces[i].id == ifaceId) if (ifaces[i].id == ifaceId)
return &ifaces[i]; return &ifaces[i];
@ -417,8 +417,8 @@ struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topo
*/ */
bool MediaDevice::populateEntities(const struct media_v2_topology &topology) bool MediaDevice::populateEntities(const struct media_v2_topology &topology)
{ {
media_v2_entity *mediaEntities = reinterpret_cast<media_v2_entity *> struct media_v2_entity *mediaEntities = reinterpret_cast<struct media_v2_entity *>
(topology.ptr_entities); (topology.ptr_entities);
for (unsigned int i = 0; i < topology.num_entities; ++i) { for (unsigned int i = 0; i < topology.num_entities; ++i) {
/* /*
@ -449,8 +449,8 @@ bool MediaDevice::populateEntities(const struct media_v2_topology &topology)
bool MediaDevice::populatePads(const struct media_v2_topology &topology) bool MediaDevice::populatePads(const struct media_v2_topology &topology)
{ {
media_v2_pad *mediaPads = reinterpret_cast<media_v2_pad *> struct media_v2_pad *mediaPads = reinterpret_cast<struct media_v2_pad *>
(topology.ptr_pads); (topology.ptr_pads);
for (unsigned int i = 0; i < topology.num_pads; ++i) { for (unsigned int i = 0; i < topology.num_pads; ++i) {
unsigned int entity_id = mediaPads[i].entity_id; unsigned int entity_id = mediaPads[i].entity_id;
@ -478,8 +478,8 @@ bool MediaDevice::populatePads(const struct media_v2_topology &topology)
bool MediaDevice::populateLinks(const struct media_v2_topology &topology) bool MediaDevice::populateLinks(const struct media_v2_topology &topology)
{ {
media_v2_link *mediaLinks = reinterpret_cast<media_v2_link *> struct media_v2_link *mediaLinks = reinterpret_cast<struct media_v2_link *>
(topology.ptr_links); (topology.ptr_links);
for (unsigned int i = 0; i < topology.num_links; ++i) { for (unsigned int i = 0; i < topology.num_links; ++i) {
/* /*