Add Subaru gearShifter to carstate
diff --git a/selfdrive/car/subaru/carstate.py b/selfdrive/car/subaru/carstate.py
index a6cd6e9f319966..669624519e303f 100644
--- a/selfdrive/car/subaru/carstate.py
+++ b/selfdrive/car/subaru/carstate.py
@@ -1,5 +1,6 @@
 import copy
 from cereal import car
+from opendbc.can.can_define import CANDefine
 from selfdrive.config import Conversions as CV
 from selfdrive.car.interfaces import CarStateBase
 from opendbc.can.parser import CANParser
@@ -11,6 +12,8 @@ def __init__(self, CP):
     super().__init__(CP)
     self.left_blinker_cnt = 0
     self.right_blinker_cnt = 0
+    can_define = CANDefine(DBC[CP.carFingerprint]['pt'])
+    self.shifter_values = can_define.dv["Transmission"]['Gear']
 
   def update(self, cp, cp_cam):
     ret = car.CarState.new_message()
@@ -35,6 +38,9 @@ def update(self, cp, cp_cam):
     self.right_blinker_cnt = 50 if cp.vl["Dashlights"]['RIGHT_BLINKER'] else max(self.right_blinker_cnt - 1, 0)
     ret.rightBlinker = self.right_blinker_cnt > 0
 
+    can_gear = int(cp.vl["Transmission"]['Gear'])
+    ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None))
+
     ret.steeringAngle = cp.vl["Steering_Torque"]['Steering_Angle']
     ret.steeringTorque = cp.vl["Steering_Torque"]['Steer_Torque_Sensor']
     ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD[self.car_fingerprint]
@@ -80,6 +86,7 @@ def get_can_parser(CP):
       ("DOOR_OPEN_RR", "BodyInfo", 1),
       ("DOOR_OPEN_RL", "BodyInfo", 1),
       ("Units", "Dash_State", 1),
+      ("Gear", "Transmission", 0),
     ]
 
     checks = [
diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py
index 353846634c978e..5cc3440997a654 100644
--- a/selfdrive/car/subaru/interface.py
+++ b/selfdrive/car/subaru/interface.py
@@ -66,7 +66,7 @@ def update(self, c, can_strings):
     be.type = car.CarState.ButtonEvent.Type.accelCruise
     buttonEvents.append(be)
 
-    events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.unknown])
+    events = self.create_common_events(ret)
 
     if ret.cruiseState.enabled and not self.cruise_enabled_prev:
       events.append(create_event('pcmEnable', [ET.ENABLE]))
diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit
index f21a4476eab258..022d6d368f1d71 100644
--- a/selfdrive/test/process_replay/ref_commit
+++ b/selfdrive/test/process_replay/ref_commit
@@ -1 +1 @@
-63ee3eaab23b45821a3a04888ae7506ec27dedb3
+852b5b42981cf17a18c7eebc9b501db2f5b0c33b

This PR adds gearShifter to Subaru carstate. Prerequiste to merging is opendbc PR https://github.com/commaai/opendbc/pull/221 which adds Transmission message and Gears values to subaru_global_2017.dbc. Tested and working on Crosstrek 2018