15976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org/*
25976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * libjingle
35976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * Copyright 2011 Google Inc.
45976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *
55976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * Redistribution and use in source and binary forms, with or without
65976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * modification, are permitted provided that the following conditions are met:
75976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *
85976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *  1. Redistributions of source code must retain the above copyright notice,
95976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *     this list of conditions and the following disclaimer.
105976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *  2. Redistributions in binary form must reproduce the above copyright notice,
115976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *     this list of conditions and the following disclaimer in the documentation
125976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *     and/or other materials provided with the distribution.
135976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *  3. The name of the author may not be used to endorse or promote products
145976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *     derived from this software without specific prior written permission.
155976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org *
165976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
175976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
185976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
195976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
205976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
215976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
225976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
235976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
245976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
255976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
265976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org */
275976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
285976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#ifndef TALK_MEDIA_BASE_CPUID_H_
295976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#define TALK_MEDIA_BASE_CPUID_H_
305976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
315976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#include "talk/base/basictypes.h"  // For DISALLOW_IMPLICIT_CONSTRUCTORS
325976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
335976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgnamespace cricket {
345976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
355976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgclass CpuInfo {
365976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org public:
375976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  // The following flags must match libyuv/cpu_id.h values.
385976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  // Internal flag to indicate cpuid requires initialization.
395976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuInit = 0x1;
405976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
415976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  // These flags are only valid on ARM processors.
425976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasARM = 0x2;
435976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasNEON = 0x4;
445976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  // 0x8 reserved for future ARM flag.
455976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
465976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  // These flags are only valid on x86 processors.
475976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasX86 = 0x10;
485976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasSSE2 = 0x20;
495976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasSSSE3 = 0x40;
505976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasSSE41 = 0x80;
515976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasSSE42 = 0x100;
525976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasAVX = 0x200;
535976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasAVX2 = 0x400;
545976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasERMS = 0x800;
555976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
565976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  // These flags are only valid on MIPS processors.
575976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasMIPS = 0x1000;
585976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasMIPS_DSP = 0x2000;
595976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static const int kCpuHasMIPS_DSPR2 = 0x4000;
605976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
615976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  // Detect CPU has SSE2 etc.
625976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static bool TestCpuFlag(int flag);
635976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
645976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  // For testing, allow CPU flags to be disabled.
655976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  static void MaskCpuFlagsForTest(int enable_flags);
665976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
675976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org private:
685976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org  DISALLOW_IMPLICIT_CONSTRUCTORS(CpuInfo);
695976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org};
705976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
715976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org// Detect an Intel Core I5 or better such as 4th generation Macbook Air.
725976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.orgbool IsCoreIOrBetter();
735976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
745976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org}  // namespace cricket
755976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org
765976650443d68ccfadf1dea24999ee459dd2819mflodman@webrtc.org#endif  // TALK_MEDIA_BASE_CPUID_H_
77