• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html>
2<!--
3Copyright (c) 2012 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7
8<link rel="import" href="/tracing/extras/importer/linux_perf/parser.html">
9
10<script>
11'use strict';
12
13/**
14 * @fileoverview Parses drm driver events in the Linux event trace format.
15 */
16tr.exportTo('tr.e.importer.linux_perf', function() {
17
18  var ColorScheme = tr.b.ColorScheme;
19  var Parser = tr.e.importer.linux_perf.Parser;
20
21  /**
22   * Parses linux drm trace events.
23   * @constructor
24   */
25  function DrmParser(importer) {
26    Parser.call(this, importer);
27
28    importer.registerEventHandler('drm_vblank_event',
29        DrmParser.prototype.vblankEvent.bind(this));
30  }
31
32  DrmParser.prototype = {
33    __proto__: Parser.prototype,
34
35    drmVblankSlice: function(ts, eventName, args) {
36      var kthread = this.importer.getOrCreatePseudoThread('drm_vblank');
37      kthread.openSlice = eventName;
38      var slice = new tr.model.Slice('', kthread.openSlice,
39          ColorScheme.getColorIdForGeneralPurposeString(kthread.openSlice),
40          ts, args, 0);
41
42      kthread.thread.sliceGroup.pushSlice(slice);
43    },
44
45    /**
46     * Parses drm driver events and sets up state in the importer.
47     */
48    vblankEvent: function(eventName, cpuNumber, pid, ts, eventBase) {
49      var event = /crtc=(\d+), seq=(\d+)/.exec(eventBase.details);
50      if (!event)
51        return false;
52
53      var crtc = parseInt(event[1]);
54      var seq = parseInt(event[2]);
55      this.drmVblankSlice(ts, 'vblank:' + crtc,
56          {
57            crtc: crtc,
58            seq: seq
59          });
60      return true;
61    }
62  };
63
64  Parser.register(DrmParser);
65
66  return {
67    DrmParser: DrmParser
68  };
69});
70</script>
71
72