1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 /** 6 * @fileoverview Parses drm driver events in the Linux event trace format. 7 */ 8 base.require('linux_perf_parser'); 9 base.exportTo('tracing', function() { 10 11 var LinuxPerfParser = tracing.LinuxPerfParser; 12 13 /** 14 * Parses linux drm trace events. 15 * @constructor 16 */ 17 function LinuxPerfDrmParser(importer) { 18 LinuxPerfParser.call(this, importer); 19 20 importer.registerEventHandler('drm_vblank_event', 21 LinuxPerfDrmParser.prototype.vblankEvent.bind(this)); 22 } 23 24 LinuxPerfDrmParser.prototype = { 25 __proto__: LinuxPerfParser.prototype, 26 27 drmVblankSlice: function(ts, eventName, args) { 28 var kthread = this.importer.getOrCreatePseudoThread('drm_vblank'); 29 kthread.openSlice = eventName; 30 var slice = new tracing.TimelineSlice('', kthread.openSlice, 31 tracing.getStringColorId(kthread.openSlice), ts, args, 0); 32 33 kthread.thread.pushSlice(slice); 34 }, 35 36 /** 37 * Parses drm driver events and sets up state in the importer. 38 */ 39 vblankEvent: function(eventName, cpuNumber, pid, ts, eventBase) { 40 var event = /crtc=(\d+), seq=(\d+)/.exec(eventBase[5]); 41 if (!event) 42 return false; 43 44 var crtc = parseInt(event[1]); 45 var seq = parseInt(event[2]); 46 this.drmVblankSlice(ts, 'vblank:' + crtc, 47 { 48 crtc: crtc, 49 seq: seq 50 }); 51 return true; 52 } 53 }; 54 55 LinuxPerfParser.registerSubtype(LinuxPerfDrmParser); 56 57 return { 58 LinuxPerfDrmParser: LinuxPerfDrmParser 59 }; 60 }); 61