18a1362adSmaya/* 28a1362adSmaya * Copyright © 2014 Broadcom 38a1362adSmaya * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org> 48a1362adSmaya * 58a1362adSmaya * Permission is hereby granted, free of charge, to any person obtaining a 68a1362adSmaya * copy of this software and associated documentation files (the "Software"), 78a1362adSmaya * to deal in the Software without restriction, including without limitation 88a1362adSmaya * the rights to use, copy, modify, merge, publish, distribute, sublicense, 98a1362adSmaya * and/or sell copies of the Software, and to permit persons to whom the 108a1362adSmaya * Software is furnished to do so, subject to the following conditions: 118a1362adSmaya * 128a1362adSmaya * The above copyright notice and this permission notice (including the next 138a1362adSmaya * paragraph) shall be included in all copies or substantial portions of the 148a1362adSmaya * Software. 158a1362adSmaya * 168a1362adSmaya * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 178a1362adSmaya * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 188a1362adSmaya * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 198a1362adSmaya * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 208a1362adSmaya * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 218a1362adSmaya * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 228a1362adSmaya * IN THE SOFTWARE. 238a1362adSmaya */ 248a1362adSmaya 258a1362adSmaya#ifndef U_DRM_H 268a1362adSmaya#define U_DRM_H 278a1362adSmaya 288a1362adSmaya#include <stdint.h> 298a1362adSmaya#include <stdbool.h> 308a1362adSmaya 318a1362adSmaya/* Does the u64 array contain the listed u64? */ 328a1362adSmaya 338a1362adSmayastatic inline bool 348a1362adSmayautil_array_contains_u64(uint64_t needle, const uint64_t *haystack, unsigned count) 358a1362adSmaya{ 368a1362adSmaya unsigned i; 378a1362adSmaya 388a1362adSmaya for (i = 0; i < count; i++) { 398a1362adSmaya if (haystack[i] == needle) 408a1362adSmaya return true; 418a1362adSmaya } 428a1362adSmaya 438a1362adSmaya return false; 448a1362adSmaya} 458a1362adSmaya 468a1362adSmaya/* Given a list of DRM modifiers and a desired modifier, returns whether the 478a1362adSmaya * modifier is found */ 488a1362adSmaya 498a1362adSmayastatic inline bool 508a1362adSmayadrm_find_modifier(uint64_t modifier, const uint64_t *modifiers, unsigned count) 518a1362adSmaya{ 528a1362adSmaya return util_array_contains_u64(modifier, modifiers, count); 538a1362adSmaya} 548a1362adSmaya 558a1362adSmaya#endif 56