summaryrefslogtreecommitdiff
path: root/src/libcamera/media_device.cpp
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2019-01-02 12:56:48 +0100
committerJacopo Mondi <jacopo@jmondi.org>2019-01-03 09:16:31 +0100
commit171f4c0a0dd1fef1e83479a341153c02b443bd2a (patch)
tree530249ea5e9f1ee7d9831ccbd5cc386f0e8ac1f3 /src/libcamera/media_device.cpp
parent4e5a93da8382cb64d3d87e7d288afed4024eed4b (diff)
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>
Diffstat (limited to 'src/libcamera/media_device.cpp')
-rw-r--r--src/libcamera/media_device.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
index e1368a13..cf4ff901 100644
--- a/src/libcamera/media_device.cpp
+++ b/src/libcamera/media_device.cpp
@@ -206,9 +206,9 @@ int MediaDevice::populate()
{
struct media_v2_topology topology = { };
struct media_v2_entity *ents = nullptr;
+ struct media_v2_interface *interfaces = nullptr;
struct media_v2_link *links = nullptr;
struct media_v2_pad *pads = nullptr;
- struct media_v2_interface *interfaces = nullptr;
__u64 version = -1;
int ret;
@@ -220,9 +220,9 @@ int MediaDevice::populate()
while (true) {
topology.topology_version = 0;
topology.ptr_entities = reinterpret_cast<__u64>(ents);
+ topology.ptr_interfaces = reinterpret_cast<__u64>(interfaces);
topology.ptr_links = reinterpret_cast<__u64>(links);
topology.ptr_pads = reinterpret_cast<__u64>(pads);
- topology.ptr_interfaces = reinterpret_cast<__u64>(interfaces);
ret = ioctl(fd_, MEDIA_IOC_G_TOPOLOGY, &topology);
if (ret < 0) {
@@ -235,15 +235,15 @@ int MediaDevice::populate()
if (version == topology.topology_version)
break;
- delete[] links;
delete[] ents;
- delete[] pads;
delete[] interfaces;
+ delete[] pads;
+ delete[] links;
- ents = new media_v2_entity[topology.num_entities]();
- links = new media_v2_link[topology.num_links]();
- pads = new media_v2_pad[topology.num_pads]();
- interfaces = new media_v2_interface[topology.num_interfaces]();
+ ents = new struct media_v2_entity[topology.num_entities]();
+ interfaces = new struct media_v2_interface[topology.num_interfaces]();
+ links = new struct media_v2_link[topology.num_links]();
+ pads = new struct media_v2_pad[topology.num_pads]();
version = topology.topology_version;
}
@@ -254,10 +254,10 @@ int MediaDevice::populate()
populateLinks(topology))
valid_ = true;
- delete[] links;
delete[] ents;
- delete[] pads;
delete[] interfaces;
+ delete[] pads;
+ delete[] links;
if (!valid_) {
clear();
@@ -402,7 +402,7 @@ struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topo
return nullptr;
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) {
if (ifaces[i].id == ifaceId)
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)
{
- media_v2_entity *mediaEntities = reinterpret_cast<media_v2_entity *>
- (topology.ptr_entities);
+ struct media_v2_entity *mediaEntities = reinterpret_cast<struct media_v2_entity *>
+ (topology.ptr_entities);
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)
{
- media_v2_pad *mediaPads = reinterpret_cast<media_v2_pad *>
- (topology.ptr_pads);
+ struct media_v2_pad *mediaPads = reinterpret_cast<struct media_v2_pad *>
+ (topology.ptr_pads);
for (unsigned int i = 0; i < topology.num_pads; ++i) {
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)
{
- media_v2_link *mediaLinks = reinterpret_cast<media_v2_link *>
- (topology.ptr_links);
+ struct media_v2_link *mediaLinks = reinterpret_cast<struct media_v2_link *>
+ (topology.ptr_links);
for (unsigned int i = 0; i < topology.num_links; ++i) {
/*